Opened 16 years ago

Closed 16 years ago

#9707 closed (worksforme)

IntegrityError with Charfield and option unique=True

Reported by: anonymous Owned by: nobody
Component: Forms Version: dev
Severity: Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

I have this model :

class Group(models.Model):
    idGroup = models.AutoField(primary_key=True)
    name = models.CharField('Name', max_length=50, unique=True)

In django admin interface when i add a Group with the same name of other Group I obtain the error

Exception Type: IntegrityError
Exception Value: (1062, "Duplicate entry 'xxxx' for key 2")

How can i have a regular validation error in admin interface ?

PS : I use Mysql with InnoDB

Thanks in advance

Change History (1)

comment:1 by Karen Tracey, 16 years ago

Resolution: worksforme
Status: newclosed

What version of Django are you using? Cut-and-pasting your model into a project and running with a current level results in admin rejecting the duplicate add with a message "Group with this Name already exists." This unique validation was added in r8805 (which was prior to 1.0). It sounds like you are running something earlier than that.

Note: See TracTickets for help on using tickets.
Back to Top