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
In Example 22.6 there are 3 model classes with a OneToOneField for user. I am trying something out for a project and defined a field like this which raises the following Django error:
some_app.SomeModel.user: (fields.E320) Field specifies on_delete=SET_NULL, but cannot be null.
app_1 | HINT: Set null=True argument on the field, or change the on_delete rule.
I suppose it would require null=True to be added to all three profiles but this would allow a profile to exist without the user.
Not sure if this would be a good idea, though.
Unless the example is purposefully kept small and this is up to the reader to decide how to deal with in the specific project.
Your full name so we can provide accurate credit within the book
Matthias Schoettle
The text was updated successfully, but these errors were encountered:
Location within the Book
Description
In Example 22.6 there are 3 model classes with a
OneToOneField
foruser
. I am trying something out for a project and defined a field like this which raises the following Django error:According to the documentation
null=True
is required forSET_NULL
.Possible Solutions
I suppose it would require
null=True
to be added to all three profiles but this would allow a profile to exist without the user.Not sure if this would be a good idea, though.
Unless the example is purposefully kept small and this is up to the reader to decide how to deal with in the specific project.
Your full name so we can provide accurate credit within the book
Matthias Schoettle
The text was updated successfully, but these errors were encountered: