Skip to content
This repository has been archived by the owner on Feb 7, 2019. It is now read-only.

Fix for #129 (prefetch_related foreign_key-related object with queryset) #131

Merged
merged 1 commit into from
Feb 9, 2017

Conversation

brki
Copy link
Contributor

@brki brki commented Feb 6, 2017

This commit is for Django 1.8.x.

This should be easily adaptable to work with Django 1.9+, too:
See get_prefetch_queryset() in
django.db.models.field.related_descriptors.ForwardManyToOneDescriptor.

This commit is for Django 1.8.x.

This should be easily adaptable to work with Django 1.9+, too:
See get_prefetch_queryset() in
django.db.models.field.related_descriptors.ForwardManyToOneDescriptor.
Copy link
Contributor

@maennel maennel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job, thanks @brki

# related_field = self.field.foreign_related_fields[0]
related_field = namedtuple('VersionedRelatedFieldTuple', 'name')('identity')

# FIXME: This will need to be revisited when we introduce support for
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we take over this comment or rather make a reference to the relative place in the Django base: https://github.com/django/django/blob/1.8/django/db/models/fields/related.py#L560 ?
Since, basically, this has not much to do with CleanerVersion itself, since "just" monkey-patching.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My (perhaps misguided) reasoning was that if the logic in the parent classes code changes at some point, it will be easier to see the differences and figure out what needs to be changed if this code is as similar as possible.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ok, fine for me. Let's go ahead...

@maennel maennel merged commit a6eaf2b into master Feb 9, 2017
@maennel maennel deleted the prefetch_related_with_queryset_fix branch February 9, 2017 11:25
maennel pushed a commit to maennel/cleanerversion that referenced this pull request Sep 10, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants