19.5.4 Post-Authentication Redirection

If you log in to the website, you’ll discover that Django tries to redirect us to the /accounts/profile/ URL path segment, a webpage that doesn’t exist. That’s rather silly.

We can change this behavior by overriding the LOGIN_REDIRECT_URL. In Example 19.45, we also define the LOGIN_URL and LOGOUT_URL settings, which will be useful in Chapter 20.

Example 19.45: Project Code

suorganizer/settings.py in a4c0b0aec0

166   from django.core.urlresolvers import reverse_lazy 167 168   LOGIN_REDIRECT_URL = reverse_lazy('blog_post_list') 169   LOGIN_URL = reverse_lazy('dj-auth:login') 170   LOGOUT_URL = reverse_lazy('dj-auth:logout')

This is a great start, but we can do much better. Users ...

Get Django Unleashed now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.