-
Notifications
You must be signed in to change notification settings - Fork 36
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
[Feature Request] Django requests not compatible with interia request payloads? #21
Comments
Per discord conversation, this is what I have so far (maybe a naive implementation) which could hopefully give people access to inertia request data out of the box. # settings.py - Setting for parsing application/json requests and placing data in request.JSON. If you are using something like Django Rest Framework, this is done already and available through request.data, so it can be disabled here.
INERTIA_PARSE_JSON_REQUEST = True
# middleware.py
if settings.INERTIA_PARSE_JSON_REQUST and request.body and 'application/json' in request.content_type:
try:
request.JSON = json.loads(request.body)
except json.JSONDecodeError:
request.JSON = {} |
@ChrisxHart You can pass the following argument to form.post(usePage().url, { forceFormData: true }); |
I like the idea of baking some json support into Inertia Django because it's such a tightly coupled concept. @svengt's solution is perfect if you want to maintain Django standards, but for those who don't, I think I'm going to add something very similar to what @ChrisxHart wrote there into core. It'll probably be a very similar syntax, just lazily evaluated. Thanks both of you, I'll leave this open until I have a PR up. |
closing per #30 |
I've run into another snag. When attempting to post interia js forms the django request only includes the payload in a raw bytestring via
request.body
.request.POST
is empty as that's only populated from traditional form submissions. I'm unable to accesskey
param in the view without processing therequest.body
bytestring first, which seems totally out of scope for individual projects to handle. DRF has solutions for this, but DRF shouldn't necessarily be required for this adapter to work I wouldn't think? Is there a way for the adapter to handle this?The text was updated successfully, but these errors were encountered: