Quickstart¶
After Installation, you can use django-filechooser in your templates.:
Load the filechooser library and use the filechooser_* tags:
Example template¶
{# Load the tag library #}
{% load filechooser %}
{# Load CSS #}
{% filechooser_css %}
{# Display a filetabel #}
{% filechooser_filetable id="identifier" %}
{# Load CSS and JavaScript #}
{% filechooser_javascript id="identifier" %}
{# Read the documentation for more information #}
Example urls.py¶
Note we request an object from the views to retrieve an url object to be added to the list urls
urlpatterns = patterns('',
url(r'^$', views.choose, name='choose'),
# Add the url-pattern as generated by the filechooser
views.filechooser().url_pattern()
)
Example views¶
# Import the FileChooser object
from filechooser import FileChooser
# Define a method which returns a FileChooser, with a certain ID field (this must
# be the same as the one defined in the template) and root directory for the file
# browsing and finally a callback method to process the selected file
def filechooser():
return FileChooser("identifier", settings.FILEBROWSER_DIRECTORY, process)
# Define a method to handle selected files.
def process(filename):
# do something with filename received from the filechooser
Template tags and filters¶
Refer to Template tags and filters for more information.
Settings¶
You can set defaults for django-filechooser in your settings file. Refer to settings for more information.