Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I select a folder in a Django form?

Tags:

forms

django

Is there a simple way to allow the user to select a folder from a Django form? I want to use the same widget as for a FileField, but only allow the user to select a folder so I can process all the files in that folder.

Thanks.

like image 734
Jeff Wilson Avatar asked Apr 12 '12 14:04

Jeff Wilson


People also ask

How do I change directory in Django?

Changing Directories (pwd) In order to go backwards, or up your file system tree, (i.e. go from Desktop/ back to Rohan/), you have to use the command "cd ..": cd ..

How to give File path in Django?

FilePathField in Django Forms is a string field, for input of path of a particular file from server. It is used for select inputs from the user. One needs to specify which folders should be used in FilePathField and field displays the inputs in form of a select field. The default widget for this input is Select.

What is form Is_valid () in Django?

The is_valid() method is used to perform validation for each field of the form, it is defined in Django Form class. It returns True if data is valid and place all data into a cleaned_data attribute.


1 Answers

It is impossible, you will never receive a directory name back from the type="file" input button

like image 90
Sholomitcky Avatar answered Sep 25 '22 17:09

Sholomitcky