Re: UniqueConstraint raises uncaught IntegrityError in Admin

2019-07-17 Thread Michael Barr
That's what I had to revert to doing, yes. I added logic to the validate_unique() method on the model itself and then updated the query logic manually. On Wednesday, July 17, 2019 at 2:15:52 AM UTC-4, Derek wrote: > > Would it be correct to say that adding validation at model clean level >

Re: UniqueConstraint raises uncaught IntegrityError in Admin

2019-07-17 Thread Derek
Would it be correct to say that adding validation at model clean level would make more sense when using this feature with the admin? On Tuesday, 9 April 2019 15:13:19 UTC+2, Simon Charette wrote: > > No form validation is implemented for UniqueConstraint(condition) yet as > that would require >

Re: UniqueConstraint raises uncaught IntegrityError in Admin

2019-07-15 Thread Michael Barr
Yeah, this one just bit me in the Django Admin as well. According to the docs , Validation of Constraints > > In general constraints are *not* checked during full_clean(), and do not > raise ValidationErrors. Rather you’ll get a

Re: UniqueConstraint raises uncaught IntegrityError in Admin

2019-04-09 Thread Simon Charette
No form validation is implemented for UniqueConstraint(condition) yet as that would require a non-trivial refactor of how it's performed. It was discussed during the feature development[0]. I'd suggest you override you form or your model's clean() method to perform the validation yourself

Re: UniqueConstraint raises uncaught IntegrityError in Admin

2019-04-09 Thread Robin Riis
The Integrity error means that there is a row in the database with role = 1 So another row with role=1 would break the unique constraint and is not allowed. So either remove the unique constraint or make sure it will be unique. Den tis 9 apr. 2019 13:29Ryan Jarvis skrev: > Hey there, > > I'm

UniqueConstraint raises uncaught IntegrityError in Admin

2019-04-09 Thread Ryan Jarvis
Hey there, I'm trying out the new UniqueConstraint functionality in Django 2.2 and seem to be misunderstanding something. When adding a Constraint to the model I am getting an uncaught IntegrityError in the admin. I've got the following sample code: *models.py* class Seminar(models.Model):