1👍
✅
You can’t. But you can use a closure instead.
def emailform(emailmodel):
class EmailPreferences(forms.ModelForm):
...
class Meta:
model = emailmodel
...
return EmailPreferences
...
form = emailform(teacher_email_preferences)()
Source:stackexchange.com