Django AdminSite
login_form, .
admin.py
class MyAdminSite(AdminSite):
login_form = CustomAdminLoginForm
admin_site = MyAdminSite(name='myadmin')
admin_site.register(User)
admin_site.register(Group
urls.py
Django
from app.admin import admin_site
url(r'^admin/', admin_site.urls)
forms.py
AuthenticationForm confirm_login_allowed
, .
class CustomAdminLoginForm(AuthenticationForm):
def confirm_login_allowed(self, user):
if user.last_login:
raise ValidationError(mark_safe('Hey first time user please reset your password here... <a href="/test">test</a>'), code='inactive')
: .
- , .? last_long None.
date_joined
. last_login == date_joined
- , ?
Edit:
config_login_allowed
...?
from django.contrib.auth.signals import user_logged_in
def change_password_first_time(sender, user, request, **kwargs):
user_logged_in.connect(change_password_first_time)