I'm using a 3rd part app(django-registration), and need to modify the validation rules for my own favor.
One way is to extend the form(RegistrationForm), and override the fields with my own validation rules.
#registration/forms.py
class RegistrationForm(forms.Form):
username = forms.RegexField(regex=r'^[\w.@+-]+$',
max_length=30,
...
)
...
In my own apps:
class RegistrationForm(RegistrationForm):
username = forms.RegexField(regex=r'(?ui)^[\w.@+-]+$',
min_length=3,
max_length=20,
...
)
...
But it's always a problem where I should put this extended form in my own code.
Another idea is to embed the registration app in my own project folder, and modify it directly. It's easier to do, but feels like a problem regarding OOP.
Wondering what's the best way of doing it?