1π
β
I donβt know your views, but i think you can do something like that:
# in forms.py
class NormalUserForm(forms.Form):
# Your normal account form here
name = forms.CharField()
class PremiumUserForm(NormalUserForm):
# inherit from NormalUserForm, and add fields
premium_field = forms.TextField()
# in views.py
def is_premium(user):
# Find a better way
return user.userprofile.account_type == 2
class SomtFormView(FormView):
template = 'sometemplate.html'
def get_form_class(self):
if is_premium(self.request.user)
return PremiumUserForm
return NormalUserForm
π€Leandro
Source:stackexchange.com