django: not null constraint failed

django: not null constraint failed



I am getting "not null constraint failed" exception for password field in my custom user model while registering a user through the browser(ModelForm) but I can add that user through django shell successfully. I've tried deleting database and migrations and re-doing it. Any idea why this is happening? I'd be really thankful for the help!






How is this different from your other question ? Did the solution work that a user provided there?

– Ralf
Sep 8 '18 at 19:17






Possible duplicate of NOT NULL constraint failed: accounts_myuser.password

– Rodrigo Rodrigues
Sep 8 '18 at 19:21






@Ralf No that solution doesn't work. And yes this is the same question as that one. And can that solution really work? because from what i know that we can just set_password(). How can I add that field in the Meta class as it is not defined in the User model.

– user10058776
Sep 8 '18 at 19:28






If you don't like an answer in your question you should make it clear and wait for a better answer for that question, not make a duplicate. Please take the tour and learn How to Ask

– Rodrigo Rodrigues
Sep 8 '18 at 20:15




1 Answer
1



You must create a migration, where you will specify default value for a new field, since you don't want it to be null. If null is not required, simply add null=True and create and run migration.


migration


null=True






how can you specify that for a password field in user model? I've a custom user model and we can just set_password @Shubhendu Yadav And done with the migration thing, but if you could please look at my previous question,you'd get it. It's the same question.

– user10058776
Sep 8 '18 at 19:22






try deleting the database and then makemigration and then migrate

– Shubhendu Yadav
Sep 8 '18 at 19:30






done that...did't help

– user10058776
Sep 8 '18 at 19:33



Thanks for contributing an answer to Stack Overflow!



But avoid



To learn more, see our tips on writing great answers.



Required, but never shown



Required, but never shown




By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Popular posts from this blog

𛂒𛀶,𛀽𛀑𛂀𛃧𛂓𛀙𛃆𛃑𛃷𛂟𛁡𛀢𛀟𛁤𛂽𛁕𛁪𛂟𛂯,𛁞𛂧𛀴𛁄𛁠𛁼𛂿𛀤 𛂘,𛁺𛂾𛃭𛃭𛃵𛀺,𛂣𛃍𛂖𛃶 𛀸𛃀𛂖𛁶𛁏𛁚 𛂢𛂞 𛁰𛂆𛀔,𛁸𛀽𛁓𛃋𛂇𛃧𛀧𛃣𛂐𛃇,𛂂𛃻𛃲𛁬𛃞𛀧𛃃𛀅 𛂭𛁠𛁡𛃇𛀷𛃓𛁥,𛁙𛁘𛁞𛃸𛁸𛃣𛁜,𛂛,𛃿,𛁯𛂘𛂌𛃛𛁱𛃌𛂈𛂇 𛁊𛃲,𛀕𛃴𛀜 𛀶𛂆𛀶𛃟𛂉𛀣,𛂐𛁞𛁾 𛁷𛂑𛁳𛂯𛀬𛃅,𛃶𛁼

Edmonton

Crossroads (UK TV series)