#23338: Warn when unique=True is set on ForeignKey
--------------------------------------+------------------------------------
     Reporter:  funkybob              |                    Owner:  JLinden
         Type:  New feature           |                   Status:  assigned
    Component:  Core (System checks)  |                  Version:  master
     Severity:  Normal                |               Resolution:
     Keywords:  afraid-to-commit      |             Triage Stage:  Accepted
    Has patch:  0                     |      Needs documentation:  0
  Needs tests:  0                     |  Patch needs improvement:  0
Easy pickings:  1                     |                    UI/UX:  0
--------------------------------------+------------------------------------

Comment (by timgraham):

 On the PR Carl says,

  Is this check worth adding? A unique `ForeignKey` works just fine and
 doesn't hurt anyone. If `ForeignKey(unique=True)` makes more sense to
 someone, or if they just changed it to be unique and have a bunch of
 existing accessor code that they don't want to have to change to
 OneToOneField style, is there really any value in Django complaining at
 them about it?

  I think if we do add this, the warning needs to be carefully worded so as
 not to imply that there's anything wrong or broken about
 `ForeignKey(unique=True)`, because there isn't; it's just that they may
 find the `OneToOneField` accessor slightly more convenient if they weren't
 aware of that option. But to me this seems like a coding-style thing that
 doesn't warrant a check warning.

--
Ticket URL: <https://code.djangoproject.com/ticket/23338#comment:7>
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/066.bf79262ee1cec2370be6d36b910bf698%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to