Skip to content
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

Can't get shared_data to work #29

Open
Fidel-C opened this issue Oct 30, 2023 · 6 comments
Open

Can't get shared_data to work #29

Fidel-C opened this issue Oct 30, 2023 · 6 comments

Comments

@Fidel-C
Copy link

Fidel-C commented Oct 30, 2023

The exact example in the docs just doesn't work in my case, or was anything omitted in the docs? The idea of having to pass the same data to all views, which is now the only alternative, doesn't seem quite nice.

@dr3tt
Copy link

dr3tt commented Nov 5, 2023

Did you add your middleware in settings MIDDLEWARE?

settings.py

MIDDLEWARE = [
    ...
    "inertia.middleware.InertiaMiddleware",
    "core.middleware.inertia_share",
]

@fidelesq
Copy link

fidelesq commented Nov 6, 2023

Thanks, will see if this works. Because I'm just seeing the second middleware ("core.middleware.inertia_share") for the first time.

@fidelesq
Copy link

fidelesq commented Nov 6, 2023

And I noticed that after form request using useForm()
from the inertia vue the response comes like a modal containing the json as strings instead of pure json responses. Any fix for that?

@fidelesq
Copy link

fidelesq commented Nov 7, 2023

"core.middleware.inertia_share" throws errors

@dr3tt
Copy link

dr3tt commented Nov 7, 2023

"core.middleware.inertia_share" throws errors

"core" is your django app (usually you have at least one)
"middleware" is your middleware python module (middleware.py)
"inertia_share" is your middleware function (located inside middleware.py)

https://docs.djangoproject.com/en/4.2/topics/http/middleware/#activating-middleware

@BrandonShar
Copy link
Collaborator

Hey @Fidel-C, I don't know of any issues here and this is working fine in my apps so I suspect it's something on your end that isn't clear in the docs. Could you provide some more information about your setup?

Thanks @dr3tt for the debugging help!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants