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

Middleware causes double view execution #9

Closed
user-1024 opened this issue Sep 24, 2022 · 1 comment
Closed

Middleware causes double view execution #9

user-1024 opened this issue Sep 24, 2022 · 1 comment

Comments

@user-1024
Copy link

I noticed after adding the request middleware my loging calls to some views where run twice.
I think this might be because get_response is called twice in the middleware.

( Possibly also related structure of my django app. )

@user-1024 user-1024 changed the title Middle ware causes double view execution Middleware causes double view execution Sep 24, 2022
@user-1024
Copy link
Author

Yes actually adding return response in the end of the if case in the middleware seems to fix this issue.
If you don't return the response the middleware will call self.get_response(request) again and this can ( depending on the middle-ware order ) cause a secondary execution of the view.
I'll make a quick pull for this.

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

1 participant