Django – after login, redirect user to his custom page –> mysite.com/username

A simpler approach relies on redirection from the page LOGIN_REDIRECT_URL. The key thing to realize is that the user information is automatically included in the request. Suppose: LOGIN_REDIRECT_URL = ‘/profiles/home’ and you have configured a urlpattern: (r’^profiles/home’, home), Then, all you need to write for the view home() is: from django.http import HttpResponseRedirect from django.urls … Read more

Can I access constants in settings.py from templates in Django?

If it’s a value you’d like to have for every request & template, using a context processor is more appropriate. Here’s how: Make a context_processors.py file in your app directory. Let’s say I want to have the ADMIN_PREFIX_VALUE value in every context: from django.conf import settings # import the settings file def admin_media(request): # return … Read more