Skip to content
This repository has been archived by the owner on Nov 25, 2017. It is now read-only.

Fix for pjaxtend with HttpResponse w/ test #11

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

jlovison
Copy link

I added radiosilence's fix (#9) along with a test that returns a HttpResponse while decorated with pjaxtend.

The test failed prior to the change, and passes after the try/except.

@johannes-gehrs
Copy link

I am not sure if this is a perfect implementation (if you use the library and you are unaware that you need to use a TemplateResponse, things will "fail silently" from the point of view of the user) but something like this is definitely needed.

For example many of my views (I guess anyone's?) have redirects in them. As soon as a redirect is returned rather than a TemplateResponse an error is thrown. This seems like a very common case to me.

There is also another issue right at this part of the code: The Django API allows TemplateResponses to have None as a Context object. In this case there's also an Error because None is treated as if it were a Dict. I think one has to check whether the Context is None and if that's the case then an empty Dict has to be assigned instead.

Maybe @kromem would be willing to add that to the pull request?

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

Successfully merging this pull request may close these issues.

2 participants