#21832: allow USERNAME_FIELD to be a ForeignKey -------------------------------------+------------------------------------- Reporter: cjerdonek | Owner: nobody Type: New feature | Status: new Component: contrib.auth | Version: master Severity: Normal | Resolution: Keywords: | Triage Stage: Accepted USERNAME_FIELD,ForeignKey,foreign | Needs documentation: 0 key,auth,username | Patch needs improvement: 0 Has patch: 0 | UI/UX: 0 Needs tests: 0 | Easy pickings: 0 | -------------------------------------+-------------------------------------
Comment (by cjerdonek): > Other than createsuperuser, is there anything currently preventing this from working? Yes, pretty much anywhere that `USERNAME_FIELD` appears in the code needs to be reviewed, for example `AbstractBaseUser.get_username()` and `RemoteUserBackend.authenticate()`. In my experience, though, most of these can be dealt with through straightforward subclassing and overriding. However, the `createsuperuser` command was the most awkward to deal with. I wound up overriding the command, but the solution I'm currently using is brittle and somewhat of a hack (relying on internal details, etc). My hope for this issue is to reduce these barriers. In other words, I wouldn't mind if foreign keys aren't supported out of the box, but it would be nice if it were easier to make things work (and in a way that's more likely to work in future versions of Django, etc). -- Ticket URL: <https://code.djangoproject.com/ticket/21832#comment:8> 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 django-updates+unsubscr...@googlegroups.com. To post to this group, send email to django-updates@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-updates/067.8b46239b7c5415c2bbb0d7e0389d5594%40djangoproject.com. For more options, visit https://groups.google.com/groups/opt_out.