'HttpResponse' object has no attribute 'render'
See original GitHub issueHi there, Firstly, GREAT app and exactly what I had in mind with wagtail! Thank you.
Just found a small “bug” with the build management command when a content object returns an HttpResponse object that has already rendered
bakery/views/base.py
self.get(self.request).render().content
throws
AttributeError: 'HttpResponse' object has no attribute 'render'
The “fix” on my side was to
resp = self.get(self.request)
if hasattr(resp, 'render'):
return resp.render().content
elif hasattr(resp, 'content'):
return resp.content
else:
raise Exception('Response has no content')
Which is a little ugly especially in the else case… but I was just wanting to “make it work” on my side.
settings
BAKERY_MULTISITE = True
BAKERY_VIEWS = (
'wagtailbakery.views.AllPublishedPagesView',
)
BUILD_DIR = '/tmp/asset-manager-build/'
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (3 by maintainers)
Top Results From Across the Web
'HttpResponse' object has no attribute '_committed'
I am working with a Django project, where I am trying to render a pdf and save it in my database. my models.py...
Read more >'HttpResponseRedirect' object has no attribute '_meta'
I have the following code in views.py class OrganisationAddView(CreateView): model = models.Organisation fields = ( 'full_name' ...
Read more >'SafeText' object has no attribute 'status_code' - Google Groups
Try using render or render_to_response instead of render_to_string. A view needs to return and HttpResponse object, not a string.
Read more >Responses - Django REST framework
Unlike regular HttpResponse objects, you do not instantiate Response objects with rendered content. Instead you pass in unrendered data, which may consist ...
Read more >Python's urllib.request for HTTP Requests - Real Python
The code in the finally block first checks if the response object exists with is not None , and then closes it. That...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Just ran into this issue again with
HttpResponseRedirect
response objects. Probably you userender_to_response
orrender
shortcuts in your Wagtail page. Will provide a fix for this!Master should now work fine!