Re: template {% url } tag syntax

2017-02-26 Thread Carsten Fuchs

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(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+unsubscr...@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.


Re: template {% url } tag syntax

2017-02-26 Thread Richard Belew
i should also probably say that the url spec is in the djggApp's specific 
urls.py file, included in the project's urls.py

my primary reference is the url tag reference doc 
 but i 
must not be composing its arguments correctly?

-- 
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+unsubscr...@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/830f40b0-9ebd-4c7e-b272-94338be1e7e7%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


template {% url } tag syntax

2017-02-26 Thread Richard Belew

i have a hardwired URL in my template:

/djggApp/guest/{{ guest.guestId }}/update/

that successfully matches against this url pattern:

url(r'^guest/(\d+)/update$', login_required(views.GuestUpdate.as_view()), 
name='updateGuest'),


now i am trying to replace the template code with a more modern reverse 
lookup via a url tag:

{% 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: []*


-- 
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+unsubscr...@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/693fabd3-a170-4228-9d40-711567ab580b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.