Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Avoid AttributeError for PUT and PATCH methods when using APIView #778

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

Merged
sliverc merged 12 commits into django-json-api:master from bpleshakov:patch-4
Apr 18, 2020

Conversation

Copy link
Contributor

@bpleshakov bpleshakov commented Apr 10, 2020
edited
Loading

Fixes silenced AttributeError in the case when lookup_url_kwarg doesn't exist in a view

Description of the Change

Checklist

  • PR only contains one change (considered splitting up PR)
  • unit-test added
  • documentation updated
  • CHANGELOG.md updated (only for user relevant changes)
  • author name in AUTHORS

Copy link
Member

sliverc commented Apr 11, 2020

As lookup_field and lookup_url_kwarg are set in GenericAPIView can you give an example in what case a lookup field is actually not set?

Copy link
Contributor Author

bpleshakov commented Apr 14, 2020
edited
Loading

@sliverc both of these fields aren't set whenever you use default APIView. It is a valid DRF behavior.

UPD: I think I should explain a little bit more. Nothing stops a user to define APIView whatever they want and set DRF-JA JSONParser and JSONRenderer to obtain JSON-API endpoint without an underlying model using some plain serializer. It is not a common case, but we have this usage in our product.

The problem here is that AttributeError you supposed to expect here is caught by DRF request proxy without any notification and unfortunately there is nothing we can do with such behavior.

Copy link

codecov bot commented Apr 14, 2020
edited
Loading

Codecov Report

Merging #778 into master will increase coverage by 0.04%.
The diff coverage is 100.00%.

Impacted file tree graph

@@ Coverage Diff @@
## master #778 +/- ##
==========================================
+ Coverage 97.16% 97.21% +0.04% 
==========================================
 Files 55 55 
 Lines 2825 2874 +49 
==========================================
+ Hits 2745 2794 +49 
 Misses 80 80 
Impacted Files Coverage Δ
example/tests/test_parsers.py 100.00% <100.00%> (ø)
rest_framework_json_api/parsers.py 97.43% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 5f19ef0...fc9c390. Read the comment docs.

Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

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

That makes sense. Could you follow up by adding a test and changelog entry then? Thanks.

@sliverc sliverc changed the title (削除) 409 conflict on different ids works with bug (削除ここまで) (追記) 409 conflict on different ids when using APIView (追記ここまで) Apr 14, 2020
Copy link
Member

@sliverc sliverc left a comment

Choose a reason for hiding this comment

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

Thanks. This looks good.

@sliverc sliverc changed the title (削除) 409 conflict on different ids when using APIView (削除ここまで) (追記) Avoid AttributeError for PUT and PATCH methods when using APIView (追記ここまで) Apr 18, 2020
@sliverc sliverc merged commit ff0f93a into django-json-api:master Apr 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Reviewers

@sliverc sliverc sliverc approved these changes

+1 more reviewer

@auvipy auvipy auvipy approved these changes

Reviewers whose approvals may not affect merge requirements
Assignees
No one assigned
Labels
None yet
Projects
None yet
Milestone
No milestone
Development

Successfully merging this pull request may close these issues.

AltStyle によって変換されたページ (->オリジナル) /