Thank you for your help

I just learnt about the url funciton but went with 

(r'^myform/$', 'mysite.views.myform', {}, 'myform')

as it would be the same as other patterns in urls.py

Thanks again




________________________________
 From: Alexis Roda <alexis.roda.villalo...@gmail.com>
To: django-users@googlegroups.com 
Sent: Sunday, August 5, 2012 4:51:46 PM
Subject: Re: named url patterns - invalid syntax
 
Al 05/08/12 13:43, En/na Blaxton ha escrit:
> 
> Hi
> 
> Why following line cause an invalid syntax :
> (r'^myform/$', 'mysite.views.myform', name="myform"),

Because it's syntax is invalid: the 'name=value' is allowed in function calls 
but not in tuples.

Try with:

urlpatterns = patterns('',
    url(r'^myform/$', 'mysite.views.myform', name="myform"),
    ...
)

> it seems named url pattern has changed from name="myform" to just 'myform'
> because when I change it to:
> (r'^myform/$', 'mysite.views.myform', 'myform'),
> 
> it pass the syntax error and throw another error :
> 
> dictionary update sequence element #0 has length 1; 2 is required

When you use a tuple the syntax is:

(regular expression, Python callback function [, optional dictionary [, 
optional name]])

the third element, if present, is expected to be a dictionary. Try with:

(r'^myform/$', 'mysite.views.myform', {}, 'myform')




HTH

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

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

Reply via email to