#29631: Feature Request: models.UniqueBooleanField()
-------------------------------------+-------------------------------------
Reporter: Michael | Owner: nobody
Type: New | Status: new
feature |
Component: Database | Version: 2.1
layer (models, ORM) |
Severity: Normal | Keywords:
Triage Stage: | Has patch: 0
Unreviewed |
Needs documentation: 0 | Needs tests: 0
Patch needs improvement: 0 | Easy pickings: 0
UI/UX: 0 |
-------------------------------------+-------------------------------------
Imagine the schema for a tweet on Twitter:
{{{
class Tweet(models.Model):
content = models.Charfield(max_length=280)
user = models.ForeignKey(User)
pinned = models.UniqueBooleanField(default=False, unique_with='user')
}}}
The user pins a tweet and behind the scenes `UniqueBooleanField` would set
the previous tweet's pinned field to False (if any) and set the current
one to True. This has tons of other use cases, including: the default
group for a user and anything where there can only be one "default" given
a `unique_with` property.
Is this a dumb idea? Is there already a better, more Django-idiomatic way?
All feedback is appreciated.
Thanks,
Michael
--
Ticket URL: <https://code.djangoproject.com/ticket/29631>
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/050.430ea88a532187cd34a2d9ac6dcdbef0%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.