Skip to content

Option to exclude Django Field blank option from determination of 'nullable' #1446

@tomatod

Description

@tomatod

Is your feature request related to a problem? Please describe.
When blank=True is specified at a Djang Field, ModelSchema treats the field as nullable even if null=False is also specified there. So, ModelSchema passes null to the Django model and it raise NOT NULL constraint exception.

class CharFieldVerification(models.Model):
    char_field = models.CharField(max_length=200, blank=True, null=False)

class TextFieldVerification(models.Model):
    text_field = models.TextField(blank=True, null=False)

class DateFieldVerification(models.Model):
    date_field = models.DateField(blank=True, null=False)

class FileFieldVerification(models.Model):
    file_field = models.FileField(blank=True, null=False)

class BooleanFieldVerification(models.Model):
    boolean_field = models.BooleanField(blank=True, null=False)

Image

The combination of blank=True and null=False seems to be common in string-based Django fields, which is mentioned in Django Model field reference

Other related Issue

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions