INSERT INTO "rk_news3"
("news_title","news_text","news_more","news_date","news_keywords")
VALUES ('testtitle','test text','','2006-10-17 12:10:00.106753','foo
bar')
###################################
It worked before and I can add things from the "user view" (forum
works). I use postgresql and django-SVN. I've reset the counters (like
ALTER SEQUENCE rk_page1_id_seq RESTART 1;) but it still throw this
error.
We'd need to see your model. And, why did you restart the sequences?
Michael
I'm curious about why you reset the sequence, rather than using
setval() to push it up to a working value, but this just sounds like a
sequence that's gotten out of sync with the state of its associated
table. And without a lot more information about what's going on (how
many apps access the database, for example, and what they use to do
it), it'd be hard to track down how that happened.
--
"May the forces of evil become confused on the way to your house."
-- George Carlin
#################
class News(models.Model):
news_title = models.CharField(maxlength=255, verbose_name='Tytul')
news_text = models.TextField(verbose_name='Tresc')
news_more = models.TextField(verbose_name='Rozszerzona Tresc',
blank=True, default='')
news_date = models.DateTimeField(auto_now_add = True, blank=True)
news_keywords = models.CharField(maxlength=255, verbose_name='Slowa
Kluczowe', db_index=True)
class Meta:
verbose_name = "Nowosc"
verbose_name_plural = "Nowosci"
db_table = 'rk_news' + str(settings.SITE_ID)
class Admin:
list_display = ('news_title', 'news_date')
list_filter = ['news_date']
search_fields = ['news_title', 'news_text']
date_hierarchy = 'news_date'
fields = (
(None, {
'fields': ('news_title', 'news_text', 'news_keywords')
}),
('Rozszerzona Tresc', {
'classes': 'collapse',
'fields' : ('news_more',)
}),)
def __str__(self):
return self.news_title
class Page(models.Model):
title = models.CharField(maxlength=255, verbose_name='Tytul')
slug = models.SlugField(maxlength=255, unique=True,
verbose_name='Odnosnik', prepopulate_from=['title'])
description = models.CharField(maxlength=255, verbose_name='Opis')
text = models.TextField(verbose_name='Tresc')
creation_date = models.DateTimeField(auto_now_add = True, blank=True)
modification_date = models.DateTimeField(auto_now = True, blank=True)
class Meta:
verbose_name = "Strona"
verbose_name_plural = "Strony"
db_table = 'rk_page' + str(settings.SITE_ID)
class Admin:
list_display = ('title', 'slug')
search_fields = ['title', 'text', 'description']
fields = (
(None, {
'fields': ('title', 'slug', 'description', 'text')
}),)
def get_absolute_url(self):
return '/w/p/' + self.slug + '/'
def __str__(self):
return self.slug
######################
User views show the data and the Admin Panel is used for add/edit work.
manage.py sqlsequencereset <appname> | psql <db_name>
It sets counters to the max value of serial field of every model in
your app.
I tried to migrate some (1,000s rows) tables from mysql to postgresql
with the build-in model functions, which is absolutely no problem.
While when I tried to add new data with manipulator.save(), it always
raise "integrity error" on the primary key.
It fixed the problem with the reset on _id_seq. Thanks!