Nice
One of the things that bother me the most about constraint violation (both unique and check) in Django is that it's difficult to identify which constraint failed *exactly*. For example, if you have two "unique_together"s... You'll need to dig into the IntegrityError.
-
-
-
I think this is the databases’ fault for not providing more structured data, not django’s. That said the error messages tend to be well structured so perhaps we could extract it?
- Još 2 druga odgovora
Novi razgovor -
-
-
Nice writeup Adam. I can say I've learned something today!
-
Glad to be of service!
Kraj razgovora
Novi razgovor -
-
-
So run into this same issue and solved it a slightly different way. Rather than "real" database constraints via the constraints hooks, instead I did the following https://gist.github.com/tomleo/5a81fc34f0e29dff9ece871c1709c479 … tl;dr override the model save and clean methods.
-
Great idea. Unfortunately this won’t apply in the cases of bulk_create, bulk_update, update_or_create, Model.objects.update(), or raw SQL :(
- Još 1 odgovor
Novi razgovor -
-
-
Wow, the right article at the right moment!! A very good reason to update to django3 :) I was using a nice third party library in some projects (Choices of django-models-utils) but this is now better because is built-in!
Hvala. Twitter će to iskoristiti za poboljšanje vaše vremenske crte. PoništiPoništi
-
Čini se da učitavanje traje već neko vrijeme.
Twitter je možda preopterećen ili ima kratkotrajnih poteškoća u radu. Pokušajte ponovno ili potražite dodatne informacije u odjeljku Status Twittera.