/tests/regressiontests/admin_views/forms.py

https://code.google.com/p/mango-py/ · Python · 10 lines · 8 code · 2 blank · 0 comment · 1 complexity · cd5aca154690e61bc790827ebc87ec21 MD5 · raw file

  1. from django import forms
  2. from django.contrib.admin.forms import AdminAuthenticationForm
  3. class CustomAdminAuthenticationForm(AdminAuthenticationForm):
  4. def clean_username(self):
  5. username = self.cleaned_data.get('username')
  6. if username == 'customform':
  7. raise forms.ValidationError('custom form error')
  8. return username