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 commit9777442. Thanks to trac username troygrosfield for the report and test case. Backpatch ofcb83448891from master. Conflicts: tests/prefetch_related/models.py
This commit is contained in:
committed by
Anssi Kääriäinen
parent
b6acc4f749
commit
b107421acf
@@ -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']
|
||||
|
||||
Reference in New Issue
Block a user