-
-
Notifications
You must be signed in to change notification settings - Fork 7k
Respect to_field property of ForeignKey relations #2435
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Closed
Closed
Changes from 1 commit
Commits
Show all changes
15 commits
Select commit
Hold shift + click to select a range
067360c
Added support for the to_field on ForeignKey Fields.
Harper04 8263048
* many to many relationship do not have to_fields
Harper04 d47f29a
Fixed the rest of the test cases.
Harper04 49ecaa7
Add support for Django <1.6 where appearently no to_field existed
Harper04 6369f93
* Removed 2 unnecessary lines
Harper04 6007463
Merge branch 'master' of https://github.com/tomchristie/django-rest-f…
Harper04 f808b6c
* Removed SlugRelatedField optimization
Harper04 77eeefa
Merge branch 'master' of https://github.com/tomchristie/django-rest-f…
Harper04 3dd5ddd
Merge branch 'master' of https://github.com/tomchristie/django-rest-f…
Harper04 6ccc45e
Ups. Removed the wrong line. (optimizer)
Harper04 64c49f8
From this i believe it is field_name pre django 1.6. I still don’t ha…
Harper04 a496c52
to_field is rel.field_name at <1.6. love pdb and pip!
Harper04 8096997
Merge branch 'master' of https://github.com/tomchristie/django-rest-f…
Harper04 54e16f4
Merge branch 'master' into model-tofield-serializer
Harper04 5ca9841
* updated patch to latest DRF revision
Harper04 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
* Removed SlugRelatedField optimization
* Moved compatibility check of to_fields to compat.py * Expanded the check with a way that should work on django <1.6. Need to check trevis after pushing..
- Loading branch information
commit f808b6c6bc8c78df5bed5ddeb1556c21fc09bd5b
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -303,14 +303,7 @@ def __init__(self, slug_field=None, **kwargs): | |
|
|
||
| def to_internal_value(self, data): | ||
| try: | ||
| # Some tests do not have the full QuerySet API | ||
| # But we optimize SlugRelatedFields by only loading what we need | ||
| qs = self.get_queryset() | ||
| if hasattr(qs, 'only'): | ||
| return self.get_queryset().only(self.slug_field).get(**{self.slug_field: data}) | ||
| else: | ||
| return self.get_queryset().get(**{self.slug_field: data}) | ||
|
|
||
| return self.get_queryset().only(self.slug_field).get(**{self.slug_field: data}) | ||
|
||
| except ObjectDoesNotExist: | ||
| self.fail('does_not_exist', slug_name=self.slug_field, value=smart_text(data)) | ||
| except (TypeError, ValueError): | ||
|
|
||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I still have to work on that one. Reading some more of that old code.