Welcome, Guest: Register On Nairaland / LOGIN! / Trending / Recent / NewStats: 3,195,128 members, 7,957,240 topics. Date: Tuesday, 24 September 2024 at 09:38 AM |
Nairaland Forum / Science/Technology / Programming / Django Developers Help Out With This Error (1056 Views)
Android Developers Help Me Out / Python Django Developers Circle / Hire Django Developers: Freelancers Vs Agencies (2) (3) (4)
Django Developers Help Out With This Error by sparkle7: 8:08am On Jun 04, 2019 |
Am getting intergrity error on django. Can you guys help identify the problem.
|
Re: Django Developers Help Out With This Error by ogunsinamayowa(m): 8:23am On Jun 04, 2019 |
The error is telling you that you failed to provide input for a field that could not be null in the database. The field is author_id. |
Re: Django Developers Help Out With This Error by sparkle7: 8:41am On Jun 04, 2019 |
ogunsinamayowa:But i thought the author id is auto incremented? |
Re: Django Developers Help Out With This Error by kingkuntaval: 10:09am On Jun 04, 2019 |
use stackoverflow. |
Re: Django Developers Help Out With This Error by Badilstical(m): 10:40am On Jun 04, 2019 |
First I'd ask you what did you do last while it was working fine? I would probably guess you added a property to your model, if that's the case you have to delete your migration and manage.py makemigration and then migrate BUT NOTE: Only of you on development on production you might loss you database Try that if it works let us know here |
Re: Django Developers Help Out With This Error by ogunsinamayowa(m): 10:52am On Jun 04, 2019 |
sparkle7: Yes and no. In your case, because you want to override the django inbuilt object instance id, you need to put primary_key=True on the field of author_id and it would automatic. You need to populate the field and it cannot be null. I couldn't see author_id field in your model. Perhaps, you have deleted the field without updating the database(makemigrations). |
Re: Django Developers Help Out With This Error by Nobody: 2:34pm On Jun 04, 2019 |
Try importing get_user_model from django.contrib.auth and replacing settings.AUTH_USER_MODEL with get_user_model(). You're probably getting the issue cause you didnt set settings. AUTH_USER_MODEL |
Re: Django Developers Help Out With This Error by rammyblog: 2:17pm On Jun 05, 2019 |
The error is in your views.py file The post_new function is where the issue lies. The reason you are getting the error is because whenever you want to save a new post, the author id is set as NULL which is not supposed to be. To solve the issue where you had post = form.save(commit='false') Change it to post = form.save(commit=False) False should be a boolean value type not a string.. Hope that helps.. Contact me on fb for questions regarding Django fb.com/onasanyatunde |
(1) (Reply)
How To Hack Android Phones With Androrat / Becoming A Data Scientist / Developers!! Get In
(Go Up)
Sections: politics (1) business autos (1) jobs (1) career education (1) romance computers phones travel sports fashion health religion celebs tv-movies music-radio literature webmasters programming techmarket Links: (1) (2) (3) (4) (5) (6) (7) (8) (9) (10) Nairaland - Copyright © 2005 - 2024 Oluwaseun Osewa. All rights reserved. See How To Advertise. 12 |