7

I'm writing generic functions (using hasattr, setattr, getattr ...), in order to manage and update field values for a given field field_name of a certain model?

Is there a way to check if the field my_model.field_name allows null values?

dolma33
  • 4,133
  • 6
  • 28
  • 48

1 Answers1

11

Yes, this way:

ModelName._meta.get_field('field_name').null
mutantacule
  • 6,913
  • 1
  • 25
  • 39