--
Ticket URL: <https://code.djangoproject.com/ticket/18668>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* stage: Unreviewed => Accepted
* needs_tests: => 0
* needs_docs: => 0
Comment:
It took me quite some time to understand the problem described here, but I
think it's valid.
I'll rephrase it to ensure we're talking about the same thing, and for the
benefit of other contributors.
The OP's description translates to the following models:
{{{
from django.db import models
class Bar(models.Model):
pass
class Foo(models.Model):
name = models.CharField(max_length=100)
bar = models.ForeignKey(Bar)
}}}
With these definitions, you can do:
{{{
bar.foo_set.all()
Bar.objects.filter(foo__name__contains='xxx')
}}}
Now, if you add `related_name='fizz_set'` to the `ForeignKey` declaration,
you can do:
{{{
bar.fizz_set.all()
Bar.objects.filter(fizz_set__name__contains='xxx')
# ^^^^-- ugly!
}}}
And if you add `related_name='fizz'` it doesn't improve the situation:
{{{
bar.fizz.all()
# ^^^^-- ugly!
Bar.objects.filter(fizz__name__contains='xxx')
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/18668#comment:1>
* has_patch: 0 => 1
Comment:
https://github.com/django/django/pull/693
--
Ticket URL: <https://code.djangoproject.com/ticket/18668#comment:2>
* needs_better_patch: 0 => 1
Comment:
Part of what's included in the PR above was committed in
99b467f272da91b8894dc90d793d8d2c40b78d8c and
12cb0df10f12e715bcaafbee4290c92d4ed6f111. It looks like the PR contains
some things that weren't added (e.g. adding this on generic relations) but
it needs to be updated to merge cleanly.
--
Ticket URL: <https://code.djangoproject.com/ticket/18668#comment:3>
* status: new => closed
* resolution: => fixed
Comment:
#22207 [b77f26313cddbfde20dcf2661e9bd35458c2d1bd] fixed the remaining case
of generic relations.
--
Ticket URL: <https://code.djangoproject.com/ticket/18668#comment:4>