Opened 19 years ago
Closed 18 years ago
#3548 closed (wontfix)
add a direct mapping when using ForeignKey fields with unique=True in place of the deprecated OneToOneField
| Reported by: | mrmachine <real dot human at mrmachine dot net> | Owned by: | nobody |
|---|---|---|---|
| Component: | Database layer (models, ORM) | Version: | dev |
| Severity: | Keywords: | 121-rewrite | |
| Cc: | real.human@… | Triage Stage: | Design decision needed |
| Has patch: | no | Needs documentation: | no |
| Needs tests: | no | Patch needs improvement: | no |
| Easy pickings: | no | UI/UX: | no |
Description
OneToOneField sets up a direct mapping to the related object in the ORM, e.g. when relating Profile in your app to User in contrib.auth, you can access the profile with u.profile. as OneToOneField has a few issues and is likely going away soon, could we change ForeignKey to add a similar user friendly mapping when unique=True is specified, to save having to do something like u.profile_set.all()[0].
when only using one model to extend User, you can use the AUTH_PROFILE_MODULE setting and the User.get_profile() method, but this is specific to User, and indicates the extending model is a "profile", and can only be used with one extension of a model. for example, it may be possible to have multiple apps within a project, which all share common users, but each has specific extensions of User specific to their purpose. it's also possible to want to extend other models besides User with a OneToOne relation. in those cases, the direct mapping above would come in handy. e.g. u.blog_profile, u.intranet_profile, etc.
Change History (3)
comment:1 by , 19 years ago
| Component: | Uncategorized → Database wrapper |
|---|---|
| Owner: | changed from to |
| Triage Stage: | Unreviewed → Design decision needed |
comment:2 by , 18 years ago
comment:3 by , 18 years ago
| Keywords: | 121-rewrite added; OneToOne ForeignKey unique direct mapping ORM removed |
|---|---|
| Resolution: | → wontfix |
| Status: | new → closed |
We're not going to do this exactly -- making OneToOne work correctly is a better approach.
I think this current thoughts on this ticket are summarized by http://groups.google.com/group/django-developers/browse_thread/thread/1262e2c8c625b40f/4e7864aedf19d25f?lnk=gst&q=reverse+relation#4e7864aedf19d25f