You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
ModelSchema treats it as an optional field (which is I guess correct), but doesn't default it to an empty string. This results in integrity errors when trying to save to the db.
Excluding the field from model_fields and explicitly declaring it as:
project_description: str=""
is a workaround.
From what I understand, Django encourages the use of blank without null for text fields to avoid a mix of empty values.
Versions (please complete the following information):
Python version: 3.11
Django version: 4.2
Django-Ninja version: 1.0b2
Pydantic version: 2.4
The text was updated successfully, but these errors were encountered:
I also stumbled upon this issue.
The fix seems to be simple but I'm not sure if it won't result in other issues or if and if so why this was intentional.
See draft PR: #1374
Describe the bug
Given a model field:
ModelSchema
treats it as an optional field (which is I guess correct), but doesn't default it to an empty string. This results in integrity errors when trying to save to the db.Excluding the field from
model_fields
and explicitly declaring it as:is a workaround.
From what I understand, Django encourages the use of
blank
withoutnull
for text fields to avoid a mix of empty values.Versions (please complete the following information):
The text was updated successfully, but these errors were encountered: