-
Notifications
You must be signed in to change notification settings - Fork 301
Don't force translation of request attribute names #284
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
Don't force translation of request attribute names #284
Conversation
Codecov Report
@@ Coverage Diff @@
## develop #284 +/- ##
===========================================
- Coverage 76.35% 76.34% -0.01%
===========================================
Files 50 50
Lines 6014 6021 +7
===========================================
+ Hits 4592 4597 +5
- Misses 1422 1424 +2
Continue to review full report at Codecov.
|
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.
This change looks good to me. However I suppose it should go in the next major release since it changes default behavior.
@jerel Is there a timeline for this? |
@amw not really, would it help you out if it was merged soon or are you working from your fork? I'm guessing there's other things that we should include in a v2.2 but don't have to |
I am working from a fork, but it would comfort me if you had a current-release branch and next-release branch. Having this merged into next-release branch would: |
71fae0b
to
cb08ab5
Compare
Hi all, since this PR is quite old now and seems to have stalled, I'd like to consider closing this PR unless it finds a champion who can bring it to closure. What needs to be done to bring this to a conclusion? |
cb08ab5
to
2c8f50d
Compare
I'm not sure what's the reason this has stalled. I thought it was scheduled for 2.2, but that has come and gone. I think we should just merge it. |
After looking at this a bit more closely, it appears that this fixes a behavior that wasn't working as expected so I'm happy to merge it. Before I merge this, may I make a couple of requests?
|
This attribute key translation was advertised to be "off by default", but was in fact forced in parser. This commit makes it so that request attributes and relations are only translated back to snake_case format if JSON_API_FORMAT_KEYS setting is set.
2c8f50d
to
b7844e9
Compare
I had to revise my PR. My initial version used the same conversion that was specified by So I've left original author's I've added changelog and authors entry. I don't want to give my email in plain text so I've used what is common in Django's AUTHORS file – website address. There is info that people can use to contact me. |
@@ -1,3 +1,4 @@ | |||
Jerel Unruh <[email protected]> | |||
Greg Aker <[email protected]> | |||
Adam Wróbel <https://adamwrobel.com> |
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.
Thanks. I totally understand not wanting to put your email address. I don't like doing that either for the same reason you described. Thanks for adding your name.
@@ -4,6 +4,8 @@ | |||
from rest_framework import parsers | |||
from rest_framework.exceptions import ParseError | |||
|
|||
from django.conf import settings |
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.
Could you move this import line above the rest_framework
lines without a newline between them? This project groups third party libraries together alphabetically.
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've actually copied the style applied here from utils.py file:
https://github.com/django-json-api/django-rest-framework-json-api/blob/develop/rest_framework_json_api/utils.py
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.
Yeah, the style is a bit of a mess because it's not consistent. Don't worry about it. I created issue #344 after I left this comment above so it can be cleaned up in the future. I'll get this line 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 recommend using isort
for this kind of churn. Give it a try.
👍 This looks good to me. Thanks for being patient with this and for your contribution. Once the import is moved as commented, I'll merge the PR. |
This attribute key translation was advertised to be "off by default", but was in fact forced in parser. This commit makes it so that request attributes and relations are only translated back to snake_case format if JSON_API_FORMAT_KEYS setting is set.
I'm not mad – I don't have my model/serializer attributes named someField or SomeField. My use case is quite simple: I have a JSONField where I accept some black-box content for storage. I need to be able to return the data as it was submitted to me by users of the API.