Opened 7 years ago

Closed 7 years ago

#9707 closed (worksforme)

IntegrityError with Charfield and option unique=True

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

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 Changed 7 years ago by kmtracey

  • Needs documentation unset
  • Needs tests unset
  • Patch needs improvement unset
  • Resolution set to worksforme
  • Status changed from new to closed

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