| 1 |
from django.contrib.admin.forms import AdminAuthenticationForm |
| 2 |
from django.contrib.admin.helpers import ActionForm |
| 3 |
from django.core.exceptions import ValidationError |
| 4 |
|
| 5 |
|
| 6 |
class CustomAdminAuthenticationForm(AdminAuthenticationForm): |
| 7 |
class Media: |
| 8 |
css = {"all": ("path/to/media.css",)} |
| 9 |
|
| 10 |
def clean_username(self): |
| 11 |
username = self.cleaned_data.get("username") |
| 12 |
if username == "customform": |
| 13 |
raise ValidationError("custom form error") |
| 14 |
return username |
| 15 |
|
| 16 |
|
| 17 |
class MediaActionForm(ActionForm): |
| 18 |
class Media: |
| 19 |
js = ["path/to/media.js"] |