#23874: Admin Interface: Unique constraint in gis.db.models raises Integrity
Error
instead of the unique error message
-------------------------------------+-------------------------------------
Reporter: raratiru | Owner: nobody
Type: Uncategorized | Status: closed
Component: GIS | Version: 1.7
Severity: Normal | Resolution:
Keywords: IntegrityError, | worksforme
Unique Constraint, Admin | Triage Stage:
Has patch: 0 | Unreviewed
Needs tests: 0 | Needs documentation: 0
Easy pickings: 0 | Patch needs improvement: 0
| UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by claudep):
* status: new => closed
* resolution: => worksforme
Comment:
Thanks for the sample project, was really useful to debug the issue.
As you are manually building the Point object in your custom save()
method, the admin cannot detect magically that the point is a duplicate.
In your case, you could solve this by adding a `unique_together =
('longitude', 'latitude')` index to your model, or by providing a custom
`ModelForm` for your admin and creating the point in the form before the
unique validation. (Note that your model is not ideal in that it
duplicates data in the database, but that's another issue.)
--
Ticket URL: <https://code.djangoproject.com/ticket/23874#comment:4>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.f0ee0d04660c2abd68ac959e9bc5c63d%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.