Django-allauth: Reverse URL generation fails when using namespaced URLs.

Created on 23 Aug 2013  路  8Comments  路  Source: pennersr/django-allauth

If I include this in my urls.py:
url(r'^accounts/', include('allauth.urls', namespace="accounts")),
and then use this in a template:
{% url 'accounts:account_login' %}
it works fine and the link is rendered correctly.

But then if I visit one of the allauth pages (accounts/login, or accounts/signup, for example) I get exceptions. For instance, if I go to the login page, I will get this:

NoReverseMatch at /accounts/login/
Reverse for 'account_signup' with arguments '()' and keyword arguments '{}' not found.

The problem occurs in allauth/account/views.py, line 72.
I get similar issues in the signup page as well.

I'm not sure if this is a bug in allauth or something I'm doing wrong.

Most helpful comment

Yes it does, when I want to change the url patterns of allauth, I don't want to have to change it in all my links referencing to it.

All 8 comments

After searching a while I bumped into this: http://stackoverflow.com/questions/17663142/django-1-5-url-template-tag-and-reverse-function-not-generating-correct-url-ba
I tried changing allauth's code (both in views.py and the base.html temlate) as shown in the answer but the template change didn't work.

Namespaces are useful when you deploy the same app several times at different URLs. The app needs to be prepared for this, e.g. when reversing URLs there must be a current_app in the context.

allauth does not support namespaces. What would be the use case for deploying multiple login-related URLs at different URLs?

OK, thanks for clearing it up for me.
My use case is simply wanting to namespace all my URLs out of habit. In other words, I don't really need to do it :)
But that doesn't mean there isn't a use case for it. ;)

Out of curiosity, what changes would be required?

Have a look here:

https://docs.djangoproject.com/en/dev/topics/http/urls/#reversing-namespaced-urls

URL reversal needs special care...

Closing -- adding namespace support without a true cause / use case does not make much sense.

Yes it does, when I want to change the url patterns of allauth, I don't want to have to change it in all my links referencing to it.

I have the same case as @rikkib1997: need to customize the URLs of my system and allauth simply does not allow it.
Could we please reopen this issue?

Another common use case is allowing user organizations to have their own subdomains like my-company.site.com, and in which they can also login -- my-company.site.com/login.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

muhammedtufekyapan picture muhammedtufekyapan  路  5Comments

peterhn picture peterhn  路  4Comments

LukasKlement picture LukasKlement  路  4Comments

lukeburden picture lukeburden  路  5Comments

ConorMcGee picture ConorMcGee  路  5Comments