Select Directory

how do I create a field in django in the forms.py file to select only the folder

Can you provide more details about what you’re trying to do?

If you’re trying to allow someone to select a directory in a file upload field, you need to render the widget with the webkitdirectory attribute along with setting the allow_multiple_selected attribute on that field.

I have used filepathfield with attribute allow_folders = True in my model and created a model form , but i am not able to select a directiroy using this form

Welcome @HEMANTH777-CODER !

Please open a new topic to discuss this issue.

In your post, please include the model and form, and provide a full description of what you’re expecting to have happen, but isn’t happening.

If you are getting any kind of error message in your server console, please post the complete error message with the traceback.

(Also make sure that all code, templates, and error messages are formatted as pre-formatted text.)