How to show the specified image?

Hi all,

I’ve tried to create some application that shows the image.
In that application, user will select the name of image via radio select, and then the application will show the corresponding image in “images” directory.

I would appreciate if I could know the way to realize those functions using django.views.generic.TemplateView.

Thank you,

If these are static files, then the easiest way to do this would be to have your template include an img tag with the src attribute being the URL for that file. So the value that your form submits needs to be something your view can use to generate the URL for that particular image.

@KenWhitesell

Thank you for your reply.
Can that approach be applied to the case, images are uploaded by the users?
That is, the user will upload some images and then they will select to show one of them.

Yes, in this case you would be working with what Django refers to as Media files.

OK, I’ll be appreciate for your help!
I’ll try with that way.