[Answer]-Django profile id may not not null using get_or_create, how does it relate to the db?

1πŸ‘

βœ…

Why Django complains about an myt_userdata.id may not be null?

Because id is not a primary key and is not populated automatically though. Also, you don’t provide it on model creation, so DB does not know what to do.

Does Django tries to relate to the underline db structure, how? (for example the not NULL message comes from the model or from the DB?)

It’s an error from DB, not from Django.

You can use sql command to understan what exactly is executed on syncdb. Variant above seems to be correct table definition made from correct Django model, and I have no ide how have you got a variant below. Write a correct and clear model, and you’ll get correct and working table scheme after syncdb

πŸ‘€ilvar

Leave a comment