Thanks, this helped me too 2 years later.. :-) On Thursday, October 14, 2010 6:23:37 PM UTC+2, reduxionist wrote: > > On 14 ต.ค. 2010, at 22:24, glob...@iamsandiego.com <javascript:> wrote: > > > Hi Folks, > > > > After updating a postgres db for my django app Iam getting this error > > when I try and save new data to the db: > > > > Request Method: POST > > Request URL: http://10.50.253.200/admin/survey/gps/add/ > > Django Version: 1.2 beta 1 > > Exception Type: IntegrityError > > Exception Value: > > > > duplicate key value violates unique constraint "django_admin_log_pkey" > > > > Is there any way to correct this? > > Sounds to me like your DB update has reset the sequence > "django_admin_log_id_seq" used by postgres to get the next value for the > "auto-increment"-type id field used by django_admin_log. > > I would manually reset the sequence via the following: > > First get the id value of the last admin entry: > > select id from "django_admin_log" order by id desc limit 1; > > Then set the next value of the ID sequence to that + 1 via: > > select setval('django_admin_log_id_seq', LASTID+1); > > (replacing LASTID+1 with the result of the first query +1 obviously...) > > The other option would be to "delete * from 'django_admin_log';" so that > the old ids are gone and you can start over from 1 - but then you lose your > whole admin history which seems sub-optimal. > > Haven't run into the problem myself though, so this is just a guess, and > from a Django newbie so... > > Hope it helps! > Jonathan > >
-- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/29-tT_F6SlMJ. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.