On 13 Mai, 00:50, Daniel Roseman <roseman.dan...@googlemail.com>
wrote:
> On May 12, 11:00 pm, Holger Latz <holger.l...@googlemail.com> wrote:
>
>
>
> > Hi,
>
> > I included the Django-Profiles Module as recommended with
>
> > (r'^profiles/', include('profiles.urls')),
>
> > in my urls.py and so far it works fine.
>
> > Now I'd like to make use of an the implemented kwarg 'success_url'. As
> > far as I use it within the urls.py it works:
>
> > url(r'^create/$', views.create_profile, {'success_url': '/status'},
> > name='profiles_create_profile'),
>
> > But when I call it within the code with the reverse-function like
>
> > return HttpResponseRedirect(reverse('profiles_create_profile', kwargs=
> > { 'success_url': '/status' }))
>
> > it will raise the following exception:
>
> > "Reverse for 'profiles_create_profile' with arguments '()' and keyword
> > arguments '{'success_url': '/status'}' not found."
>
> > If I omit the kwargs it works without an error, so
> > 'profiles_create_profile' will be found! Who can give me a hint?
>
> > Cheers
> > Holger
>
> You've misunderstood the link between the extra arguments in the
> urlconf, and those in the reverse() function.
>
> In your url definition, you've hard-coded an extra parameter which is
> passed to the view in exactly the same way as one taken from the URL
> itself. However, as you've defined it there's no valid URL that
> accepts a different value for 'success_url'. But in your reverse()
> call, you're trying to dynamically pass a value for success_url, and
> there's no URL that matches that.
>
> As long as you want the value of '/status' which you originally hard-
> coded, you can leave out the kwargs in your call to reverse, since the
> actual definition of 'profiles_create_profile' doesn't take any
> arguments. But if you really want to specify it dynamically in the URL
> (and I'd think very hard about the security implications before doing
> so) you'll need to change the url definition so that success_url is an
> actual dynamic URL parameter.
> --
> DR.

Hi Daniel,

you're absolutely right: a misunderstanding.

What I like to do is passing extra options to view functions. But I
mixed it with naming URL patterns! It seems that I have to create a
*new* pattern (profiles_create_profile_url) in urls.py with the extra
option 'success_url' and call it with reverse
('profiles_create_profile_url').

Thanks!
Holger

--~--~---------~--~----~------------~-------~--~----~
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