Checking if field allows null values ​​in Django

I am writing common functions (using the hasattr

, setattr

, getattr

...) to manage and update the field values for a given field of field_name

a particular model?

Is there a way to check if a field is allowed to my_model.field_name

empty values?

+3


source to share


1 answer


Yes, in this way:



ModelName._meta.get_field('field_name').null

      

+6


source







All Articles