Answer the question
In order to leave comments, you need to log in
How to make unique boolean among all user instances?
I have several forms, one edit, the second crate, the user has several instances, they have a default boolean, how to make sure that only one default=True remains when saving, all user instances
I remember there was some kind of mixin, or overriding the save , I can not find
Answer the question
In order to leave comments, you need to log in
if self.the_only:
type(self).objects.exclude(pk=self.pk).filter(the_only=True).update(the_only=False)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question