/json-slider-demo

Image slider app for Django.

Primary LanguagePythonOtherNOASSERTION

JSON Slider Demo

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.

Demo

Play video

Install

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

Usage

  1. Go to the admin page and create a slider.
  2. Open http://127.0.0.1:8000/sliderapp/demo/ to view the slider.

License

This repo is available under Public Domain license.