A Django form widget using FilePond with image preview support
Project description
django-filepond-form-widget
A Django form widget using FilePond with image preview support.
Table of Contents
Features
- Easy Integration: Seamlessly integrates FilePond with Django forms.
- Image Preview: Provides image preview functionality out of the box.
- Customization: Configurable options to tailor the widget to your needs.
- Responsive Design: Ensures a responsive and user-friendly interface.
- Simple Form Submission: Focuses on regular file field submissions with forms, without handling server API endpoints.
- Language Selection: Automatically sets the locale based on the current language, ensuring the FilePond interface matches the user's language preferences.
- Extensible: Support for additional FilePond plugins planned for future releases.
Note: This widget is designed to work with standard form submissions. While FilePond's server property can be configured for API endpoints, this is beyond the scope of this project which aims to provide a simple form widget implementation.
Installation
Install the package using pip:
pip install django-filepond-form-widget
Alternatively, you can install it from the repository:
pip install git+https://github.com/krystofbe/django-filepond-form-widget.git
Usage
Add to Installed Apps
Add django_filepond_form_widget to your INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
# ...
'django_filepond_form_widget',
# ...
]
Include Static Files
Ensure that your templates include the necessary static files. Typically, this is handled automatically by the widget's media.
Use the Widget in Forms
from django import forms
from django_filepond_form_widget.widgets import FilePondWidget
class ExampleForm(forms.Form):
image = forms.FileField(
widget=FilePondWidget(
config={"allowImagePreview": True, "allowMultiple": False}
)
)
Create Views and Templates
from django.shortcuts import render
from .forms import ExampleForm
def upload_view(request):
if request.method == "POST":
form = ExampleForm(request.POST, request.FILES)
if form.is_valid():
# Handle uploaded file
return render(request, "example_app/success.html")
else:
form = ExampleForm()
return render(request, "example_app/upload.html", {"form": form})
Example
An example project is provided to demonstrate how to integrate and run the widget.
Run the Development Server
Navigate to the example directory and run the server using Uvicorn:
uv run python example/manage.py runserver
Access the Application
Open your browser and navigate to http://localhost:8000/upload/ to see the file upload form in action.
Testing
This project uses pytest for testing. To run the tests:
Install Development Dependencies
uv pip install -e ".[test]"
Run Tests
pytest
Contributing
Contributions are welcome! Please follow these steps:
- Fork the repository.
- Create a new branch for your feature or bugfix.
- Commit your changes with clear messages.
- Submit a pull request detailing your changes.
License
This project is licensed under the MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_filepond_form_widget-0.1.2.tar.gz.
File metadata
- Download URL: django_filepond_form_widget-0.1.2.tar.gz
- Upload date:
- Size: 134.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6963f590dbed9f8c8e0ce62a1d9459164956734f3a2b2ba685b1f7f410196802
|
|
| MD5 |
447263fc2152f60ac4d3a4fec9688291
|
|
| BLAKE2b-256 |
1969b6d84d3bb39a732e0b6a81db8b9b96c0ad0a842a8cf2243bb2938476eb3f
|
File details
Details for the file django_filepond_form_widget-0.1.2-py3-none-any.whl.
File metadata
- Download URL: django_filepond_form_widget-0.1.2-py3-none-any.whl
- Upload date:
- Size: 100.0 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
21308af3a2c315a37b3c0c99d5217acaddd70b228e37ac35c11b0ac7c9fcf3e9
|
|
| MD5 |
9755cc25835959fef76a5eb4f8fbf773
|
|
| BLAKE2b-256 |
4e51abc71c101e5778781e969d3f26f20bc157202e17cf1577d2a0a9befd223d
|