Hello everyone,

Can I return HttpResponseRedirect null in django view function if it is possible? I don’t want to refresh the page after my action. It will just do the action inside the function but the app page won’t refresh. Thank you in advance.

return HttpResponseRedirect()

No you may not.

If you’re doing a page-level GET or POST, you must return with a new page.

If you wish to submit or retrieve data without a page refresh, you must use AJAX. (Directly, using JavaScript, or indirectly using a library like htmx.)

Thank you for the response. No actually, I am not doing any POST or GET request. I only do file operations in the function.

I’m referring to how the browser invokes the view, not anything within the view itself. All these issues are related to the browser - Django itself has nothing to do with it.

1 Like