Sunday, February 26, 2017

Re: template {% url } tag syntax

Hi Richard,

Am 27.02.2017 um 04:01 schrieb Richard Belew:
> {%url 'djggApp/guest'guest.guestId 'update'%}
>
> but this generates a /NoReverseMatch/ error
>
> /Reverse for 'djggApp/guest' with arguments '(1, u'update')' and keyword
> arguments '{}' not found. 0 pattern(s) tried: []/


In the {% url %}, you use "update" as a parameter, so you should either
write

{% url 'djggApp:updateGuest' guest.guestId %}

or, for example

url(r'^guest/(\d+)/(?P<action>(update|something_else))$',
login_required(views.GuestUpdate.as_view()), name='updateGuest'),

(there are alternative ways for this, e.g. using \w+)
Note that your view must deal with the new parameter.

And in the template

{% url 'djggApp:updateGuest' guest.guestId 'update' %}

Best regards,
Carsten

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/7621d668-8793-701f-9b16-7a5dc380dfe8%40cafu.de.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment