Skip to main content

Django Theme Installer

Why?

When you start a new Django project and you are not so good in HTML or don't want to waste your time or found a beautiful free theme, you manually copy it in your django project and start editing it.
Django Theme Installer do this work for you.

Installation

$ pip install django-theme-installer

Usage

Add 'theme_installer' in INSTALLED_APPS
Then run

$ python manage.py theme_install theme_name /path/where/the/html/files/are/located

Tutorial

Let's fetch a simple html5 templates and install it

mkdir myproj
cd myproj/
virtualenv -p python3 .env
source .env/bin/activate
pip install django~=2.2
pip install --upgrade django-theme-installer
wget https://github.com/BlackrockDigital/startbootstrap-creative/archive/gh-pages.zip
unzip gh-pages.zip
django-admin startproject myproj
cd startbootstrap-creative-gh-pages/
themedir=`pwd`
cd .. && cd myproj/
awk 'NR==36{print; print "    \"theme_installer\","; next}7' myproj/settings.py > testfile.tmp && mv testfile.tmp myproj/settings.py
python manage.py theme_install creative $themedir
python manage.py runserver 8000

Open your browser to http://localhost:8000/creative/index/

Documentation

Django theme installer needs basically 3 folders to work: The source folder where the html template (html + assets dirs) is localted, the django static folder where the assets should go and the django templates folder where html files goes.
Django theme installer is build on the standard pathlib and use a recursive model. This recursive model make him capable of handling sub-themes.
Django theme installer is built over two types of classes: Loaders and Installlers

Loaders

Loaders are there to provide three folders to the ThemeInstaller class, those folders are: static_dir, templates_dir and home_dir. The home_dir can be null.

Installers

Installers are there to create and maybe modify/transform some files on the django side. For example the ThemeInstaller class install html and assets files, but ViewsInstaller creates views in app/views.py

Management command

The management command need barely two arguments: the name of the theme in django side and the path of the source html templates. We say the name of the theme here because this name is used for templates path, static path and sometimes for the app name.
positional arguments:

  • name The name of the theme, it will be the name of the app if --app is omitted
  • source The path of the theme

optional arguments:

  • --app APP The name of the app where to install the static, templates, views and urls.
  • --assets-dir ASSETS_DIR [ASSETS_DIR ...] The directory where to find assets, useful in case the assets are not in the same folder with the html files.
  • --subthemes Include sub themes, if you want to process the sub themes
  • --prefix The STATIC_URL prefix to override default static

Example:
python manage.py theme_install fine /home/xxx/themes/fine --app base

Via the client

$ theme_cl.py -n name -s /path/to/html/source/ -c /path/to/djangoproject/static/ -t /path/to/djangoproject/templates/

Via the code

>>> th = ThemeInstaller(name, "/path/to/html/source/", loader)"
>>> th.proceed()

Contributing

If you find a html theme which can't be installed with django theme installer, open an issue with the link to this theme. I will download it and fix it.
No nulled or cracked themes.
Contributions are welcome, all PRs will be reviewed and merged.

License

Feel free to use it as you want.

Metadata

Release files for django-theme-installer 0.1.6

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-theme-installer 0.1.6
File Size Uploaded
django-theme-installer-0.1.6.tar.gz 10.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-theme-installer 0.1.6
File Interpreter ABI Platform
django_theme_installer-0.1.6-py2.py3-none-any.whl Python 3, Python 2 none any Details

Total release size: 23.5 kB

Release files / django-theme-installer-0.1.6.tar.gz

Download URL django-theme-installer-0.1.6.tar.gz
Size 10.9 kB
Tags Source
SHA-256 checksum
How to use checksums
81d0a71a087428c321ec241dcb2d52a9200ec5280537c329b34f124714676bad
BLAKE2b-256 checksum
How to use checksums
ff569ed67d0f3a70b096f2f5639c6bb478329a9961c457a983926401ce32caa8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.9

Release files / django_theme_installer-0.1.6-py2.py3-none-any.whl

Download URL django_theme_installer-0.1.6-py2.py3-none-any.whl
Size 12.6 kB
Tags Python 2 Python 3
SHA-256 checksum
How to use checksums
ab44550422df5312d5b750b171c63f926feba05daca484da3981915ef932f6af
BLAKE2b-256 checksum
How to use checksums
e65bcd8b60f8278341bb8008055221191f043b3eb1cf01ab5ad5120a7387cc0b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.23.0 setuptools/46.1.3 requests-toolbelt/0.9.1 tqdm/4.46.1 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.1.6 This release

2 release files

0.1.5

2 release files

0.1.4

2 release files

0.1.3

2 release files

0.1.2

2 release files

0.1.1

2 release files

0.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page