|
|
|
```
|
|
|
|
def get_generalformclass(modelclass):
|
|
|
|
class GeneralForm(ModelForm):
|
|
|
|
def __init__(self, *args, **kwargs):
|
|
|
|
super().__init__(*args, **kwargs)
|
|
|
|
for k,f in self.fields.items():
|
|
|
|
model_field=getattr(self.Meta.model,k)
|
|
|
|
if (model_field.field.null == True):
|
|
|
|
f.required=False
|
|
|
|
class Meta:
|
|
|
|
model = modelclass
|
|
|
|
fields = '__all__'
|
|
|
|
return GeneralForm
|
|
|
|
``` |
|
|
|
\ No newline at end of file |