1
0
mirror of https://github.com/django/django.git synced 2025-10-26 15:16:09 +00:00

[1.6.x] Fixed #21410 -- prefetch_related() for ForeignKeys with related_name='+'

Regression introduced by commit 9777442.

Thanks to trac username troygrosfield for the report and test case.

Backpatch of cb83448891 from master.

Conflicts:

	tests/prefetch_related/models.py
This commit is contained in:
Loic Bistuer
2013-11-13 11:42:12 +07:00
committed by Anssi Kääriäinen
parent b6acc4f749
commit b107421acf
3 changed files with 53 additions and 2 deletions

View File

@@ -215,3 +215,18 @@ class WordEntry(models.Model):
def __str__(self):
return "%s (%s)" % (self.name, self.id)
## Ticket #21410: Regression when related_name="+"
@python_2_unicode_compatible
class Author2(models.Model):
name = models.CharField(max_length=50, unique=True)
first_book = models.ForeignKey('Book', related_name='first_time_authors+')
favorite_books = models.ManyToManyField('Book', related_name='+')
def __str__(self):
return self.name
class Meta:
ordering = ['id']