Something like that?
def model_form_factory(model_class):
class MyModelForm(forms.ModelForm):
class Meta:
model = model_class
return MyModelForm
AuthorForm = model_form_factory(Author)
BookForm = model_form_factory(Book)
Missatge de Yoo del dia dt., 28 de maig 2019
https://docs.djangoproject.com/en/2.2/topics/forms/modelforms/
In the example of model form, they say
model = Author
Is it possible to set a variable to set the model? Like could I make a variable
and set it to whatever model I’d like, then say model = var?
--
You received this message because
2 matches
Mail list logo