2010-12-02 08:44:35 +08:00
|
|
|
from django import forms
|
|
|
|
from django.contrib.admin.forms import AdminAuthenticationForm
|
2016-07-20 19:38:07 +08:00
|
|
|
from django.contrib.admin.helpers import ActionForm
|
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':
|
|
|
|
raise forms.ValidationError('custom form error')
|
|
|
|
return username
|
2016-07-20 19:38:07 +08:00
|
|
|
|
|
|
|
|
|
|
|
class MediaActionForm(ActionForm):
|
|
|
|
class Media:
|
|
|
|
js = ['path/to/media.js']
|