[Answer]-Django forms: Defining model in Meta on the fly

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)()

Leave a comment