I'm writing a web app that uses the pinax-project-account and bootstrap. When a user logs in the login view should grab the ACCOUNT_LOGIN_REDIRECT_URL and redirect the user to it. There seems to be an issue with dynamic urls though because when I do this with a static /profile/ url, there is no problem. I've traced the stacktrace to it's root which is in the account app LoginView in account.views. It seems that is where fallback_url is being assigned the value of ACCOUNT_LOGIN_REDIRECT_URL.
account.views
def get_success_url(self, fallback_url=None, **kwargs):
if fallback_url is None:
fallback_url = settings.ACCOUNT_LOGIN_REDIRECT_URL
kwargs.setdefault("redirect_field_name", self.get_redirect_field_name())
return default_redirect(self.request, fallback_url, **kwargs)
settings.py
ABSOLUTE_URL_OVERRIDES = {
"user_accounts.userprofile": lambda o: "/profile/%s/" % o.slug,
}
ACCOUNT_LOGIN_REDIRECT_URL = "profile_update"
views.py
class ProfileUpdateView(UpdateView):
template_name = "account/profile.html"
model = UserProfile
context_object_name = "profile"
slug_field = "slug"
urls.py
url(r"^(?P<slug>)/", (ProfileUpdateView.as_view()), name="profile_update")
StackTrace
Reverse for 'profile_update' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: ['profile/(?P<slug>)/']| Request Method: | POST |
|---|---|
| Request URL: | http://127.0.0.1:8000/account/login/ |
| Django Version: | 1.6.2 |
| Exception Type: | NoReverseMatch |
| Exception Value: | Reverse for 'profile_update' with arguments '()' and keyword arguments '{}' not found. 1 pattern(s) tried: ['profile/(?P<slug>)/'] |
| Exception Location: | /home/falcon/dev/tiger/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py in _reverse_with_prefix, line 429 |
| Python Executable: | /home/falcon/dev/tiger/env/bin/python |
| Python Version: | 2.7.5 |
| Python Path: | ['/home/falcon/dev/tiger/tigersite', '/home/falcon/dev/tiger/env/src/idios', '/home/falcon/dev/tiger/env/lib/python2.7', '/home/falcon/dev/tiger/env/lib/python2.7/plat-i386-linux-gnu', '/home/falcon/dev/tiger/env/lib/python2.7/lib-tk', '/home/falcon/dev/tiger/env/lib/python2.7/lib-old', '/home/falcon/dev/tiger/env/lib/python2.7/lib-dynload', '/usr/lib/python2.7', '/usr/lib/python2.7/plat-i386-linux-gnu', '/usr/lib/python2.7/lib-tk', '/home/falcon/dev/tiger/env/local/lib/python2.7/site-packages'] |
| Server time: | Tue, 6 May 2014 00:23:02 +0000 |
/home/falcon/dev/tiger/env/local/lib/python2.7/site-packages/django/core/handlers/base.py in get_response/home/falcon/dev/tiger/env/local/lib/python2.7/site-packages/django/views/generic/base.py in view/home/falcon/dev/tiger/env/local/lib/python2.7/site-packages/django/views/generic/base.py in dispatch/home/falcon/dev/tiger/env/local/lib/python2.7/site-packages/django/views/generic/edit.py in post/home/falcon/dev/tiger/env/local/lib/python2.7/site-packages/account/views.py in form_valid/home/falcon/dev/tiger/env/local/lib/python2.7/site-packages/account/views.py in get_success_url/home/falcon/dev/tiger/env/local/lib/python2.7/site-packages/account/utils.py in default_redirect/home/falcon/dev/tiger/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py in reverse/home/falcon/dev/tiger/env/local/lib/python2.7/site-packages/django/core/urlresolvers.py in _reverse_with_prefix