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:
|
2022-02-04 03:24:19 +08:00
|
|
|
css = {"all": ("path/to/media.css",)}
|
2015-03-07 18:57:52 +08:00
|
|
|
|
2010-12-02 08:44:35 +08:00
|
|
|
def clean_username(self):
|
2022-02-04 03:24:19 +08:00
|
|
|
username = self.cleaned_data.get("username")
|
|
|
|
if username == "customform":
|
|
|
|
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:
|
2022-02-04 03:24:19 +08:00
|
|
|
js = ["path/to/media.js"]
|