#5537: Remove Reverse Lookups on ForeignKeys/ManyToMany
-----------------------+----------------------------------------------------
Reporter: dcramer | Owner: nobody
Status: new | Component: Database wrapper
Version: SVN | Resolution:
Keywords: | Stage: Accepted
Has_patch: 0 | Needs_docs: 0
Needs_tests: 0 | Needs_better_patch: 0
-----------------------+----------------------------------------------------
Changes (by russellm):
* stage: Design decision needed => Accepted
Comment:
This would in no way be a performance boost. The accessors for reverse
lookups are descriptors; they aren't evaluated until they are used.
However, I'm promoting this to accepted. We don't need to add a keyword to
the ORM syntax - we can exploit ``related_name``. Here's the use case,
writ large:
{{{
class Note(Model)
text = CharField()
class Author(Model):
name = CharField()
name_notes = ManyToManyField(Note, related_name='author_names')
age = IntegerField()
age_notes = ManyToManyField(Note, related_name='author_ages')
address = CharField()
address_notes = ManyToManyField(Note, related_name='author_addresses')
}}}
In this example, related_name is a required field (to avoid namespace
collisions), and the names must be unique. This means you have to invent
unique (and meaningful) names, even if the related object is of no use.
However, if you allowed ``related_name=None`` to mean 'dont install the
related object', you could avoid the namespace collision, avoid the need
to invent unique names, and clean up the model definition.
--
Ticket URL: <http://code.djangoproject.com/ticket/5537#comment:3>
Django Code <http://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 post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---