2010-12-02 08:44:35 +08:00
|
|
|
from django.contrib.admin.forms import AdminAuthenticationForm
|
2016-07-20 19:38:07 +08:00
|
|
|
from django.contrib.admin.helpers import ActionForm
|
2020-02-12 21:48:49 +08:00
|
|
|
from django.core.exceptions import ValidationError
|
2010-12-02 08:44:35 +08:00
|
|
|
|
2011-10-14 02:51:33 +08:00
|
|
|
|
2010-12-02 08:44:35 +08:00
|
|
|
class CustomAdminAuthenticationForm(AdminAuthenticationForm):
|
|
|
|
|
2015-03-07 18:57:52 +08:00
|
|
|
class Media:
|
|
|
|
css = {'all': ('path/to/media.css',)}
|
|
|
|
|
2010-12-02 08:44:35 +08:00
|
|
|
def clean_username(self):
|
|
|
|
username = self.cleaned_data.get('username')
|
|
|
|
if username == 'customform':
|
2020-02-12 21:48:49 +08:00
|
|
|
raise ValidationError('custom form error')
|
2010-12-02 08:44:35 +08:00
|
|
|
return username
|
2016-07-20 19:38:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
class MediaActionForm(ActionForm):
|
|
|
|
class Media:
|
|
|
|
js = ['path/to/media.js']
|