It is not a primary key error. you are trying to pass 0 when inserting. This field that Django creates is an integer auto increment field. So you don't have to set it when you want to save a new record. And you do not need to declare it in your models too... let django do it for you.
If you need more help, share your code with us. Att., Rodrigo Zayit On Thu, Jan 5, 2023 at 7:08 AM Prashanth chaduvala <[email protected]> wrote: > I'm using MySQL database in django when I am creating > > Id=models.AutoField(primary_key=True) > > It's showing below error. > > -- > You received this message because you are subscribed to the Google Groups > "Django REST framework" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-rest-framework/CAH5_3zkFwXDM7Dfjgnpx8r5vhW%2BCGLEvzSoMrLO5tb84RqXquQ%40mail.gmail.com > <https://groups.google.com/d/msgid/django-rest-framework/CAH5_3zkFwXDM7Dfjgnpx8r5vhW%2BCGLEvzSoMrLO5tb84RqXquQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/django-rest-framework/CAL6GM4LE5HXQH9_dda%2BZ5ReN%2BrXQ0uaJqvdp4oMqwJBg6af%2B%3Dg%40mail.gmail.com.
