You may need to reset your auto increment counter in PostgreSQL. I remember 
having this problem once.
https://stackoverflow.com/questions/5342440/reset-auto-increment-counter-in-postgres


From: [email protected] [mailto:[email protected]] On 
Behalf Of Mei B
Sent: Friday, May 17, 2019 2:56 PM
To: Django users
Subject: Legacy DB: ID is null when .save or .create

I'm using a legacy DB with postgres. In one of my models:

class case(models.Model):
     id = models.AutoField(primary_key=True)
     case_id = models.ForeignKey(.....)
     user_id = models.ForeignKey(...)

When I'm saving or creating a new case object, I always get "null value in 
column 'id' violates not-null"

How do I get this to auto-increment?
--
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to 
[email protected]<mailto:[email protected]>.
To post to this group, send email to 
[email protected]<mailto:[email protected]>.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5d621db9-39e8-44c8-92e2-80fdabc760af%40googlegroups.com<https://groups.google.com/d/msgid/django-users/5d621db9-39e8-44c8-92e2-80fdabc760af%40googlegroups.com?utm_medium=email&utm_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c0d915c7229a4bcfb6df1b0a99c3b99a%40iss2.ISS.LOCAL.
For more options, visit https://groups.google.com/d/optout.

Reply via email to