Skip to main content

A magical fullstack framework for Django.

Project description

django-unicorn

The magical fullstack framework for Django. ✨

django-unicorn provides a way to use backend Django code and regular Django templates to create interactive experiences without investing in a separate frontend framework.

Why?

Building server-side sites in Django with the ORM and template engine is so pleasant, but once you need more interactivity on the frontend, there is a lot more ambiguity. Should you build out an entire API in Django REST framework? Should you use React or Vue.js (or some) other frontend framework?

It seems like there should be an easier way to create interactive experiences.

Demo

https://github.com/adamghill/django-unicorn/blob/master/demo.mp4

Install

  1. git clone git@github.com:adamghill/django-unicorn.git
  2. pip install -e ../django-unicorn
  3. Add django-unicorn and unicorn to INSTALL_APPS in your Django settings file
  4. Add path("unicorn/", include("django_unicorn.urls")), into your project's urlpatterns in urls.py
  5. Add {% load unicorn %} to the top of your base template file
  6. Add {% unicorn_styles %} and {% unicorn_scripts %} into your base HTML file

How to create a component

  1. python manage.py startunicorn hello-world
  2. Add {% unicorn 'hello-world' %} into the template you want to load the new hello-world component
  3. Take a look at HelloWorld class and hello-world.html template and update based on the example project

Current functionality

  • unicorn_styles, unicorn_scripts, unicorn template tags
  • Base component class
  • Handles text input, checkbox, select options, select multiple options

Developing

  1. git clone git@github.com:adamghill/django-unicorn.git
  2. poetry install
  3. poetry run example/manage.py migrate
  4. poetry run example/manage.py runserver 0:8000
  5. Go to localhost:8000 in your browser
  6. To install in another project pip install -e some_folder/django-unicorn and follow install instructions above

Minify Javascript

  1. npm install
  2. npm run-script build

Bump version

  1. npm run-script build
  2. Move django_unicorn/static/js/unicorn.min.js to appropriate folder for new version
  3. poetry version major|minor|patch
  4. poetry publish --build

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

django-unicorn-0.1.1.tar.gz (30.0 kB view hashes)

Uploaded Source

Built Distribution

django_unicorn-0.1.1-py3-none-any.whl (34.4 kB view hashes)

Uploaded Python 3

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page