Create Sadj Project
Example use for the
The Sadj distribution comes with a utility to quickly generate a new Sadj project, with a frame and a menu structure of your choice. You can then use this as your new application start-point.
The examples below use the
sadjadmin.py utility script located in the
Run the script from the command line, passing the name of the project you want to create, for example:
./scripts/sadjadmin.py -a createproject -n apple
This will create a new folder named
apple in the current folder, and populate it with a new Sadj project. You can test the new project was created correctly by running Django with the usual
python manage.py runserver command from the new folder.
You can then access the main
http://127.0.0.1:8000/ url, which should display something like the screenshot shown. The default menu structure is two submenus each with five menu items, all using a default template page, containing a basic container layout to help get your new application pages started.
By default the script will create an outline multi-page application. You can control the type of project created with two optional arguments:
-s or --spa- if this argument is present, create an outline single-page application; otherwise, create a multi-page application
-m or --mixed- create a mixed-mode (SPA and MPA) project. If this is specified, the --spa argument is ignored
A mixed project will contain both 'spa' and 'mpa' Django apps with the top-level page templates, which include the content from shared 'sabase' or 'sadjdemo' apps as required.
If the project is not mixed, it will contain either an 'mpa' or 'spa' app, which will hold both the page-wrapper and content templates.
Other Script Arguments
Further control over the script operation is given by:
-l, --location- directory in which to create the new project
-v, --verbosity- increase output verbosity, set as -v, -vv etc.
-fr FRAME, --frame- application frame choice: full or slim. If 'full', the SmartAdmin demo frame is used, which you can then cut back as you wish for your application. If 'slim' (the default), a much smaller frame is used, with the main menu and a basic header and footer, to which you can add as required. Most applications are best built by adding to the slim frame.
Running the script
You may wish to just run this script directly from the command line, but in line with Python best practice it is recommended that you use a virtual environment of your choice. Below are sample commands to create and use a virtualenv in a folder named 'venv' within the Sadj distribution on Linux, assuming you are starting in the distribution root folder:
python -m venv ./venv- create a virtualenv
source ./venv/bin/activate- activate the virtualenv
pip install -r ./scripts/requirements.txt- install argparse, django
./scripts/sadjadmin.py -h- diplay help.