views:

652

answers:

1

I have a urlpatterns like this:

urlpatterns = patterns('',
...
    (r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', info_dict, 'poll_detail'),
...

My html page template contains this:

{% if error_message %}<p><strong>{{ error_message }}</strong></p>{% endif %}

My view code contains:

    return HttpResponseRedirect(reverse('poll_detail',args=(p.id,)))

My question is, where in the reverse() call do I place my 'error_message' variable value?

Apologies if this is a stupid question but I have attempted to search the documentation.

+1  A: 

reverse() converts a view name to a URL. It does not call the view. Also, it can only set arguments in the URL; it cannot set template tags.

What you can do is make error_message an argument to the poll_detail view. This way, you can pass its value to the view using reverse().

Ayman Hourieh