On Feb 4, 11:25 am, Malcolm Tredinnick <malc...@pointy-stick.com>
wrote:
> On Tue, 2009-02-03 at 19:10 -0800, Eric Abrahamsen wrote:
> > Hi there,
>
> > I'm unable to do any testing -- my fixtures fail with a "Duplicate
> > Entry" error when loading. From what I've googled, this might have
> > something to do with a mismatch between my model definitions and the
> > sql table definition.
>
> "Duplicate Entry" is the database telling you that some column(s) with a
> unique constraint are failing the constraint check. So it's
> database-level data related and the first thing to check is the data
> you're trying to insert.

Aha! I had assumed duplicate entry meant it thought there were two
rows with the same pk. On second thought, that wouldn't make too much
sense.

This only helps a little bit, though, since none of the fields have
unique=True, none of the db columns are unique, and I've got no
unique_together constraints. The fixture is a direct output of
dumpdata, in xml format (I get the same error with JSON). The pks are
included, but there's no duplication there.

This is the full model definition: http://dpaste.com/116418/
and the full output of describe table: http://dpaste.com/116419/

If you've got a moment and can see anything in there that's obviously
wrong, I'd appreciate any pointers. Otherwise, I've got a better sense
of how to go about hunting this down now.

Thanks a lot,
Eric



> [...]
>
> > The only unusual thing about the second record is that it's the first
> > one with "characters" set to an empty string. I'm using a django
> > updated earlier in the day.
>
> If the primary key specified in the data you're trying to insert? If so,
> and it's not different between the two, that's one case of a unique
> field that will be causing you problems.
>
> If you know which two records are causing the problem, another part of
> reducing the problem to the simplest case is to try a few experiements.
> Each time, change one of the pieces of data in the second entry. At some
> point, you'll change the attribute that is causing the problem, so
> you'll at least know which one it is.
>
>
>
> > model
> > ####
>
> > class Author(models.Model):
> >   surname = models.CharField(max_length=30)
> >   given_name = models.CharField(max_length=30)
> >   slug = models.SlugField(blank=True)
> >   characters = models.CharField(max_length=6,blank=True)
> >   user = models.ForeignKey(User, blank=True, null=True)
> > ...more
>
> Yeah, that "more" bit is no doubt containing important information. For
> example, do you have a Meta inner class that is defining any
> unique_together constraints? Do any of the fields you've omitted have
> unique=True on them? Which columns in the database table require the
> entries to be unique?
>
> Regards,
> Malcolm
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to