Django Scaffold provides a build command to inspect models and generate views, urls, templates, admin etc.
env/bin/pip install -e git+git@github.com:allcaps/django-scaffold.git#egg=django-scaffold
Django Scaffold does introspection of models.py
. Create a your webapp and compose your models.
Alternatively you can inspect an existing database with the
inspectdb command.
Make sure both your app and scaffold
are in INSTALLED_APPS
:
INSTALLED_APPS = [
'your_app',
'scaffold',
...
]
The build
command generates admin, views, urls, templates and writes them to your app:
python manage.py build your_app
SITE_ID = 1
TEMPLATES[0]['OPTIONS']['context_processors'] += ['webapp.context_processors.base']
STATIC_URL = '/static/'
STATIC_ROOT = os.path.join(BASE_DIR, 'static/')
MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, 'media/')
INSTALLED_APPS += ['django.contrib.sites']
from model_mixins import BaseMixin
# For each model in models add BaseMixin:
class Foo(BaseMixin, models.Model):
Make sure your app comes before scaffold
. This makes Django find your template overrides first.
Copy the scaffold template to your_app/templates/scaffold to customise them:
cp path/to/site-packages/scaffold/templates/scaffold your_app/templates/
- Override the django template processor to make a second template language to make 'template tempelates' more readable.
- Create settings for Single and Multiple generator template names. So it is easy to customize the template sets.
- Template packages (minimal, Bootstrap, REST API, CRUD, Wagtail).
- Add get_admin_url and add admin edit buttons on page when user has access to admin.
- Add instructions.html template to display in terminal.
- Add rollback option or alternatively warn when project is not a clean checkout.