jsocol / jsocol/django-jsonview
Add input parsing
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 247
- Forks
- 35
- PR merge metrics
- No merged PRs in 30d
Description
A simple decorator that would do something like this:
# POST {"foo": "bar"}
@json_request
def my_view(request):
assert request.META['CONTENT_TYPE'] == 'application/json'
assert request.data == {'foo': 'bar'}
Not 100% sure how to handle other content-types yet. That's probably got to go into some sort of setting. Do you always want to assume JSON (e.g. try to parse it regardless of the content-type header) or respect the header? If it does respect the header, does it make sense to assign request.data = request.POST if content-type is set to application/x-www-form-urlencoded? What's the right error-handling if you can't parse JSON (or form-encoded)? 400?
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Begin with the proposed @json_request decorator and the request.META['CONTENT_TYPE'], request.data, and request.POST entry points. Resolve whether parsing follows the header, which content types are supported, and whether malformed input returns 400; done means these behaviors are specified and implemented consistently.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- django, python
- Domain
- api, backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100