Jonathan -

Thank you - select setval('django_admin_log_id_seq', LASTID+1); -
worked !
I can breathe again.

On Oct 14, 9:23?am, Jonathan Barratt <jonathan.barr...@knifeict.com>
wrote:
> On 14 ?.?. 2010, at 22:24, global...@iamsandiego.com 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: ? ? ?##
> > 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 post to this group, send email to django-us...@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.

Reply via email to