/tests/regressiontests/admin_views/forms.py
Python | 10 lines | 8 code | 2 blank | 0 comment | 1 complexity | cd5aca154690e61bc790827ebc87ec21 MD5 | raw file
Possible License(s): BSD-3-Clause
1from django import forms 2from django.contrib.admin.forms import AdminAuthenticationForm 3 4class CustomAdminAuthenticationForm(AdminAuthenticationForm): 5 6 def clean_username(self): 7 username = self.cleaned_data.get('username') 8 if username == 'customform': 9 raise forms.ValidationError('custom form error') 10 return username