Comments (11)
I think that the problem is a little more complicated. I was trying to debug this but I didn't find any fast fix. The problem could start in Django middlewares, and it seems that one of them, opens the file in stream buffer before it goes to this package. When a request goes into renderer it doesn't come into parse function because it stops earlier. More precisely it stops in rest_framework/requests.py:321 _parse() function, requests falls into first try/except then go into 336 if which return True, and return values in 337 line.
@vbabiy I'll try to write test in few hours/days
from djangorestframework-camel-case.
If anyone can help me with a test case, I can try to get this fixed.
from djangorestframework-camel-case.
I’ll try to find the project this was happening on.
from djangorestframework-camel-case.
@serendipity1004 can you test the latest version, if not PR with at least a test would be really helpful.
from djangorestframework-camel-case.
@vbabiy First, this is a really great package. Its nice to have the automated sanity of the correct casing on frontend and backend. I don't know how people do DRF without it, (it should be built into DRF!). So thank you for your work on it.
I noticed that it seems to not work on ImageField
as well.
I'm running Django 3.1.3, DRF 3.12.2 and DRF-C-C 1.2.0.
In my case the frontend would prepare the POST data like:
const getInputData = async () => {
let input = document.getElementById('profile-photo-input');
const formData = new FormData();
data.append('profile_photo', input.files[0]);
return formData;
};
And then the serializer that takes it looks like:
class UserProfilePhotoSerializer(serializers.Serializer): # noqa
profile_photo = serializers.ImageField(required=True)
Trying to send up camel case from the frontend failed, so I have to use the snake case as per the line above data.append('profile_photo')...
I'd be happy to try and provide more useful info, if you can clarify what could be added that would be useful I'll try and get it in this issue or a PR.
from djangorestframework-camel-case.
Try to use PUT instead of POST method in my case it helped.
from djangorestframework-camel-case.
Having the same issue. 😢 Has anyone else found a solution? I see there are a few other similar packages out there...has anyone tried them?
https://pypi.org/search/?q=djangorestframework-camel-case
Unfortunately I can't switch from POST to PUT, but do you have any idea what exactly is broken about the POST? @krzysieqq
Thanks!
from djangorestframework-camel-case.
It is very complicated! I tried to follow the code but still don’t understand what is happening. @krzysieqq
For me, the root failure happened here:
…/lib/python3.7/site-packages/rest_framework/fields.py
def to_internal_value(self, data):: https://github.com/vbabiy/djangorestframework-camel-case/releases
try:
# `UploadedFile` objects should have name and size attributes.
file_name = data.name
file_size = data.size
except AttributeError:
self.fail('invalid')
The function expects the data argument to be a file, but in my case it is a LIST containing one file. So file.name blows up. No idea how this is connected to the camel_case package. 🤷♀️🤣
The bug does not occur in djangorestframework-camel-case v0.2.0. I see the error when trying to upgrade to v1.2.0. User above also reported the issue in v1.1.2. I can’t quite follow what is going on with the releases here: https://github.com/vbabiy/djangorestframework-camel-case/releases but - I have everything queued up locally. If someone could give me a list of the versions between these, I can try to bissect which exact version introduced the bug (if that helps.)
I’m using:
python 3.7.10
djangorestframework==3.8.1
I want to second this @banagale : “First, this is a really great package. Its nice to have the automated sanity of the correct casing on frontend and backend. I don't know how people do DRF without it, (it should be built into DRF!). So thank you for your work on it.” And also thanks for responding so quickly!!!!! 🙏 @vbabiy
from djangorestframework-camel-case.
It's funny but I'm unable to recreate bug at new project. I also try to recreate in another project i which i had this problem, but i also I can't. I'll later try to recreate maybe
from djangorestframework-camel-case.
It's funny but I'm unable to recreate bug at new project. I also try to recreate in another project i which i had this problem, but i also I can't. I'll later try to recreate maybe
I think this is what happened for me! I ran into an issue, reported it here, then I think it uh, “went away.” I don’t remember fixing it but more like, “maybe I was mistaken about this being broken.”
I was going to mention that in my most recent reply, but it didn’t seem like that did much to stand up my previous report of the issue.
I would have wanted to have provided some follow-up that it was intermittent or something more descriptive than leaving it as though it happened and no work-around was found.
from djangorestframework-camel-case.
I encountered this problem myself. Turns out, when explicitly specifying parser_classes
you have to use CamelCaseMultiPartParser
instead of DRF's MultiPartParser
. That's it, that's the problem. Very easy to miss, very hard to spot.
from djangorestframework-camel-case.
Related Issues (20)
- djangorestframework_camel_case utils force_text HOT 1
- bug in function camel_to_underscore HOT 4
- Django 4 support HOT 4
- Can't install 1.3.0: "Failed building wheel for djangorestframework-camel-case" HOT 5
- Parsing camelcase to underscore on a string ending with a capital letter HOT 1
- No Conversion happening from Upper Case camel field to Upper case snake case
- Release tags are missing on GitHub
- Allow the use of orjson renderer
- No conversion when parsing request HOT 1
- Allow the use of drf_ujson2 renderer
- The README "build" badge links to non-existing Travis CI page
- Ignore UUID in parser HOT 1
- Allow the use of orjson parser HOT 2
- custom endpoint is not working HOT 1
- Underscoreize GET params HOT 3
- Request body arrives at view/action with camelCase
- Does not work with DjangoFilterBackend HOT 1
- Latest DRF and Django does not work HOT 1
- Recursive version of ignore_fields
- json_underscoreize in CamelCaseJSONRenderer
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from djangorestframework-camel-case.