On Mon, Jan 16, 2012 at 3:34 PM, Martin Tiršel <[email protected]> wrote:
> Hello,
>
> This is the view (minimal version without POST processing block):
>
> @transaction.commit_manually()
> def create_free(request):
>    context = {};
>    context['categories'] = Category.objects.all()
>    transaction.commit()
>    return render_to_response(
>        'advert/create_free.html',
>        context,
>        RequestContext(request)
>    )
>
> But I still get "Transaction managed block ended with pending
> COMMIT/ROLLBACK" exception. This is caused by the Category model load (due
> to lazy QuerySet that is evaluated in template processing?). If yes, I will
> have to render_to_string and then commit, right?
>

No, you could just subtly re-order your statements:


@transaction.commit_manually()
def create_free(request):
   context = {};
   context['categories'] = Category.objects.all()
   rsp = render_to_response(
       'advert/create_free.html',
       context,
       RequestContext(request)
   )
   transaction.commit()
   return rsp

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to