#29631: Feature Request: models.UniqueBooleanField()
-------------------------------------+-------------------------------------
Reporter: Michael | Owner: nobody
Type: New feature | Status: closed
Component: Database layer | Version: 2.1
(models, ORM) |
Severity: Normal | Resolution: wontfix
Keywords: | Triage Stage:
| Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 0 | UI/UX: 0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):
* status: new => closed
* resolution: => wontfix
Comment:
Hi iMerica,
Thanks for the input. Here are my thoughts:
1. There's nothing to stop you creating
[https://docs.djangoproject.com/en/2.0/howto/custom-model-fields/ a custom
field] for this. I'm not sure it's something we'd add to Django itself —
It would be a bit too special case — but if you had an implementation, we
could certainly look.
2. Assuming I've understood the use-case correctly, you could model this
with a nullable `OneToOneField`. (Each user can pin at most one of their
own tweets.) When pinning you'd just need to clear any existing pin before
saving. Then you'd just access via something like `user.pinned_tweet`.
3. I'd probably be inclined to store the `pinned_tweet` for each user in a
third table. (Do you have a profile model or such — maybe there — or just
a two-field lookup model if not.) Again here the foreign key to `User`
would be `unique` (or, the same thing, one-to-one).
Hopefully that gives you options. If you need further help please post to
[https://groups.google.com/d/forum/django-users the Django Users mailing
list].
If you come up with an implementation for your field that you think might
be good for inclusion, create a Pull Request on GitHub and re-open this
issue or post to [django-developers mailing archive the Django Developers
mailing list] to get feedback.
Thanks again.
--
Ticket URL: <https://code.djangoproject.com/ticket/29631#comment:1>
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/065.4d436219c2f0f505efdfdfe0b92221e6%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.