django - Set extra_context data according to login credentials for using in template -


well, following th documentation login in django site i'm using django.contrib.auth.views.login view in urls.py this:

url(r'^login/$', 'django.contrib.auth.views.login',{'template_name': 'login.html'},name="my_login"), 

i can pass extra_context view, want according user credentials, in case of success login search relative data user print in template name, address, etc... storing in session or that, using example {{ request.user.username }} in template can retrieve username login request, that's want searching data according username in auth_user. can view or have implement own?

regards!

you can define new view using login view, in pass extra_settings:

from django.contrib.auth.views import login auth_views_login  def login(*args, **kwargs):     extra_context = {'extra_value': 'some data here'}      return auth_views_login(*args, extra_context=extra_context, **kwargs)  

then replace django view yours in urls.py:

url(r'^login/$',     'myapp.views.login',     {'template_name': 'login.html'},     name="my_login"), 

Comments

Popular posts from this blog

css - Which browser returns the correct result for getBoundingClientRect of an SVG element? -

gcc - Calling fftR4() in c from assembly -

Function that returns a formatted array in VBA -