Hey, in django there is a `id` column by default get created for every object you create which will auto-increment so need to create here. In your case your model should be look like this:
*class Case(models.Model):* * case_id = models.ForeignKey(.....)* * user_id = models.ForeignKey(...)* *And suppose to get the model of id=1:* *Case.objects.get(id=1)thanks,Sanjeev* On Sat, May 18, 2019 at 1:42 AM Mei B <[email protected]> wrote: > 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]. > 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/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/CA%2Btz_AAxc1WPtyz%2Bc7%3D%2BGtFiLzmReLYSmobD3QdhBJpg_jxe4A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.

