0

I am trying to create a picture slideshow which will show all the png and jpg files of a folder using django.

Problem is how do I open windows explorer through django and prompt user to choose a folder name to load images from. Once this is done, how do I read all image files from this folder? Can I store all image files from this folder inside a list and pass this list in template views through context?

James Z
  • 12,104
  • 10
  • 27
  • 43
Amit Prafulla
  • 361
  • 2
  • 5
  • please add your code for help you !! – Diego Avila Aug 30 '18 at 19:45
  • Django won't be able to open a file selection dialog directly - it is a web server framework. You will need to upload the files to the web server for django to do anything with them. – warpri81 Aug 30 '18 at 20:08
  • This might help you, https://stackoverflow.com/questions/5871730/need-a-minimal-django-file-upload-example – Max Ballard Aug 30 '18 at 20:15

1 Answers1

0

This link “https://github.com/csev/dj4e-samples/tree/master/pics” shows how to store data into to database(sqlite is the database used here) using Django forms. But you cannot upload an entire folder at once, so you have to create a one to many model between display_id(This is just a field name in models you can name it anything you want) and pics. Now you can individually upload all pics in the folder to the same display _id and access all of them using this display_id. Also make sure to pass content_type for jpg and png separately while retrieving the pics.