Answer the question
In order to leave comments, you need to log in
How to set/read cookie in django login form?
Can you please tell me how to install and then read cookies in the built-in registration form of the framework?
@login_required(login_url='/login')
def index(request):
....
url(r'^login/$', 'cconline.views.card_login'),
...
def card_login(request, *args, **kwargs):
"""
Авторизация, истечение срока сессии - 1 день
:param request:
:param args:
:param kwargs:
:return:
"""
if request.method == 'POST':
if not request.POST.get('remember_me', None):
request.session.set_expiry(0)
else:
request.session.set_expiry(86400)
return login(request, *args, **kwargs)
Answer the question
In order to leave comments, you need to log in
The mailing came to me rather late. :) The question is somehow strangely formulated, in the form of registration through `request.session`, it is even used in the view from your example.
https://docs.djangoproject.com/en/1.9/topics/http/...
Don't forget to tweak SessionMiddleware.
Do you want the login that was used in the last successful authorization to be substituted in the authorization form? Set with a signal, details here
https://docs.djangoproject.com/en/1.9/ref/contrib/...
The form also has access to request, an example is here stackoverflow.com/questions/2373867/django-access- ...
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question