SmartAdmin for Django: Overview
Welcome to SmartAdmin for Django (Sadj), a way for you to integrate the beauty and functionality you love in SmartAdmin with the power and ease of development of Django.
Why SmartAdmin for Django
Why SmartAdmin
In a word: concinnity, defined as "An instance of harmonious arrangement or studied elegance and facility", or "an internal harmony or fitness; mutual adaptation of parts". As you're here looking at SmartAdmin for Django, you have probably noticed already how the many UI components work beautifully with each other, which ever theme choices you select.
With SmartAdmin-based pages and components, you know your product will be functional and look fantastic.
Why Django
Django is a high-level Python web framework that encourages rapid development and clean, pragmatic design. Built by experienced developers, it takes care of much of the hassle of web development, so you can focus on writing your app without needing to reinvent the wheel.
Django is also a perfect fit with SmartAdmin, and the SmartAdmin for Django package provides a range of examples and tools to help you get your first projects together in record time.
Fast to Develop
Django was designed to help developers take applications from concept to completion as quickly as possible.
Secure
Django takes security seriously and helps developers avoid many common security mistakes.
Scalable
Some of the busiest sites on the Web leverage Django’s ability to quickly and flexibly scale, including Instagram, National Geographic, Mozilla, Spotify, Pinterest, Disqus and Bitbucket. So you don't have to worry about your project scaling as you grow.
Package Contents and Quick-Start
When you purchase SmartAdmin for Django, you will receive a zip-file download; unzip to your location of choice and follow the quick-start instructions below to get going.
Quick Start
First, download the sadj zip file from wrapbootstrap, e.g. sadj_1.0.3.zip. The example below assumes unzipping to a folder on a Linux home drive.
mkdir ~/sadj
unzip sadj_1.0.3.zip -d ~/sadj
A virtualenv (or an alternative such as Docker) is always recommended when installing Python packages, though you may have your own standards in place: here we assume a virtualenv within a folder named venv
:
cd ~/sadj/
python3 -m venv ./venv
source ./venv/bin/activate
pip install -r ./scripts/requirements.txt
pip install -r ./website/requirements.txt
Next run the Django migrations. This could take a while as it loads the data for the demo website into the sqlite database.
cd ./website/
python manage.py migrate
And run the webserver:
python manage.py runserver
You should now be able to access the documents and the SmartAdmin pages using any of these urls, assuming your Django instance is running on port 8000:
- http://127.0.0.1:8000/mpa/docs_general.html - SmartAdmin and Sadj demo pages served by Django as a multi-page app
- http://127.0.0.1:8000/spa/#docs_general.html - The same pages served as a single-page app
- http://127.0.0.1:8000/demo/#sadj_docs - Sadj demo pages only
To access the full demo site functionality requires a Django login, so first create a superuser. Enter the following command and follow the prompts to create a username and password of your choice:
python manage.py createsuperuser
Then navigate to http://127.0.0.1:8000/demo/login/ to access the login screen. Enter the newly-created login details and you will be able to access the demo site; as this is a superuser. you can create new users directly via the Django admin pages.
Create a new project
You may wish to simply inspect the contents of the folders and copy across the assets and code snippets required into your own Django project, built according to your project standards. However, there is utility script to help speed new projects along, sadjadmin.py
in the scripts folder, see Create Project for more details..
To view the arguments available when running the script run these commands:
cd ~/sadj/scripts/
./sadjadmin.py -h
This is an example of creating a new project:
./sadjadmin.py -a create -n 'mango' -l ../apps -vv
which should create a 'mango' project at sadj/apps/mango
, with a default menu structure containing two submenus of five blank pages each. You can then use this new project and folder structure as the basis of your next project.
Django Application Overview and Use
See Project and Applications for more details.
- In line with Django best practice
sadjmaster
is a project acting essentially as small holder for the settings file and url redirection; no logic, no models sadjcore
is the logic (Python and Javascript) most likely to be of use in users' own projects. This should be included in your project to access the full capability of the Sadj framework.sadjdemo
is an implementation of various features into a demo frame, using sadjcorespa
andmpa
are wrappers, whilesabase
contains a refactored set of the raw SmartAdmin assets.
Licensing: Sadj and SmartAdmin-HTML5
The SmartAdmin components (css/js/html etc.) within the Sadj distribution are from two of the 'dist' (distribution) folders in the base SmartAdmin-HTML5 project, which are in turn built from sass/hbs base contents using nodejs and gulp.
The SmartAdmin for Django licence enables reuse of the components within the Sadj distribution package. If you wish to re-generate custom versions of the SmartAdmin assets, you must ALSO have the 'HTML5' SmartAdmin licence in order to run the nodejs/gulp scripts.