6👍
There are two ways to do this depending on what you want to do.
-
If you just want an image to be shown without any HTML, then just use a normal function view rand return a
HttpResponse
or if you really, really really want to use class based views override theget
method and return aHttpResponse
. -
If you want to show an HTML page with the image embedded somewhere in it. Then you can do two things
-
Create a separate view that will respond with just the image as you did in your example, and in your HTML page just add
<img src="path to that view url" />
. -
Or if you don’t want a separate view for the image then you have to create an image in the DetailView, save it to byte stream, base64 encode it and return it in your context as (for example)
image
. Then in your template you create an image tag with the base64 encoded data using<img src="data:image/png;base64,{{ image }}"/>
.
-
- [Django]-413 Request Entity Too Large – Regular Fix Not Working
- [Django]-Django-extensions test_error_logging
- [Django]-How do I include an external CSS file as a rule for a class inside a .scss file?