This app implements an image slider using JSONField
.
It uses django-jsonform to create a dynamic, user-friendly form for editing JSON.
A JSONField
yields better performance than ForeignKey
when querying
is not required. An image slider is a perfect use case of this (see supplementary blog post for more).
This app exists to showcase some of the features of django-jsonform. As such, consider modifying this app as per your needs.
0. Note:
It is assumed that you already have a Django project set up (with media serving enabled).
1. Clone or download this repo.
Then copy the sliderapp
folder into your Django project.
2. Install django-jsonform:
This dependency is required for creating a user-friendly JSON editing form in the admin.
pip install -U django-jsonform
3. Update settings
# settings.py
INSTALLED_APPS = [
...
'django_jsonform',
'sliderapp',
]
4. Include URLs
# project/urls.py
urlpatterns = [
...
path('sliderapp/', include('sliderapp.urls')),
]
5. Apply migrations
python manage.py migrate
- Go to the admin page and create a slider.
- Open http://127.0.0.1:8000/sliderapp/demo/ to view the slider.
This repo is available under Public Domain license.