0

I'm really stuck with this one.

I have the following in my urlpatterns:

url(r'^user/$', UserView.as_view(), name='farmauth-user'),
url(r'^user/(?P<id>\d+)/confirm/(?P<token>\w+)/$', UserConfirmationView.as_view(), name='farmauth-confirm'),

I have other URLs too. Then in my HTML I get

Reverse for 'farmauth-confirm' with arguments '([u'28'], [u'n48DsSASbKhabWXzZ6XV'])' and keyword arguments '{}' not found.

When I do this:

{% url 'farmauth-confirm' id token %}

I also tried using positional arguments. In case you are wondering, the URLs are visible where I'm attempting this because this works:

{% url 'farmauth-user' %}

I tried other URLs with and without arguments. It never works when using arguments. What am I doing wrong??

Please advise.

3
  • That moment I spend hours trying to figure it out, as soon as I make the post I get it right -.-; When passing the arguments to my view I was doing this: return render(request, 'confirm.html', dict(self.get_form_context(), **request.GET)) It seams that GET arguments are arrays, so the token and ID where given as [id] and [token]. Now I do this: kwargs = { 'id': request.GET.get('id'), 'token': request.GET.get('token'), } return render(request, 'confirm.html', dict(self.get_form_context(), **kwargs)) And it works. Commented May 19, 2013 at 0:01
  • I can't post as answer yet. I'll do it later. Commented May 19, 2013 at 0:02
  • Looks like you figured it out, but your url has type integer for id, but the url is evaluating id as a unicode. Hence the error. Commented May 19, 2013 at 2:35

1 Answer 1

1

Just try another order:
url(r'^user/(?P\d+)/confirm/(?P\w+)/$', UserConfirmationView.as_view(), name='farmauth-confirm'),
url(r'^user/$', UserView.as_view(), name='farmauth-user'),

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.