passing extra parameters with named urls

424 views
Skip to first unread message

DragonSlayre

unread,
Dec 18, 2008, 5:21:31 PM12/18/08
to Django users
Hi,

I'm currently working with django-registration, and have the following
url pattern (it's included from my other url pattern):

url(r'^register/$',
register,
name='registration_register',
),

This calls a view:

def register(request, success_url=None,
form_class=RegistrationForm, profile_callback=None,
template_name='registration/registration_form.html',
extra_context=None):

My Question is, how do I pass the register method the extra_context ?

What I'm trying to do is something like this:
url(r'^register/$',
register,
name='registration_register',
extra_context = {'section' : 'main'},
),

But this gives me an error 'url() got an unexpected keyword argument
'extra_context'. This seems like it'd be a simple little thing, but I
haven't seen any examples online about how you pass in the extra
parameters with named urls.

Masklinn

unread,
Dec 18, 2008, 5:41:17 PM12/18/08
to django...@googlegroups.com
You might be interested in reading the documentation, specifically http://docs.djangoproject.com/en/dev/topics/http/urls/#passing-extra-options-to-view-functions

DragonSlayre

unread,
Dec 18, 2008, 6:00:23 PM12/18/08
to Django users
url(r'^register/$',
register,
{'extra_context' : {'currentmaintab' :
'account'}},
name='registration_register',
),

It would have been nice if you could have told me straight up.

Masklinn

unread,
Dec 19, 2008, 5:19:01 AM12/19/08
to django...@googlegroups.com
On 19 Dec 2008, at 00:00 , DragonSlayre wrote:
> url(r'^register/$',
> register,
> {'extra_context' : {'currentmaintab' :
> 'account'}},
> name='registration_register',
> ),
>
Good now you know Django has a nice and complete documentation, and
next time you're going hungry you can go fishing on your own.

> It would have been nice if you could have told me straight up.

Not in the long run no.

Reply all
Reply to author
Forward
0 new messages