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