Skip to content
Advertisement

Django IntegrityError (1048, “Column ‘item_id_id’ cannot be null”)

JavaScript

Here is my models.py

JavaScript

Items model from different App:

JavaScript

My views.py

JavaScript

Forms.py

JavaScript

My template

JavaScript

And the form when i run the server is this:

Advertisement

Answer

In you model the field is named item_id but in your ModelForm the field is named itemID. The field names should be the same.

Rename the fields in your ModelForm so they match the Model.

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement