django-storeys
is the server counterpart of storeys
. It lets you generate the skeleton of a single page app using storeys, basing on an existing Django app.
cd ${MY_DJANGO_APP}
mkdir -p ${MY_DJANGO_APP}/submodules
git submodule add submodules/django-storeys
git submodule update --recursive --init
ln -s submodules/django-storeys lib/storeys
Run collect_storeys_routes
django management command.
It collects urls.js
files with routes based on urls.py
.
python tests/manage.py collect_storeys_routes
This command scans all applications inside the current project for urls.py
to create route files 'urls.js` for the client-side use.
It creates stub for TemplateView
or StoreysView
, and other views is ignored!
# application/urls.py
# Will be included into Storeys routes
url('^test/$', StoreysView.as_view(
template_name='index.html',
),
name='tests'
),
# Will be included into Storeys routes
url('^another_test/$', TemplateView.as_view(
template_name='index.html',
),
name='tests_view'
),
# Will be ignored and not included into routes. Due to `TestView`
url('^another_test/$', TestView.as_view(
template_name='index.html',
),
name='tests_view'
),
Storeys let you specific urlpatterns
to exclude. The references of excluded urls can be added in non_exported_urlpatterns
tuples.
# application/urls.py
# ...
# Url patterns `admin.site.urls`, and named patterns with names `exclude2` and `test` will be ignored by parser.
non_exported_urlpatterns = (
urlref(module_name='admin.site.urls'),
urlref(name='exclude2'),
urlref(name='test'),
)
python tests/manage.py runserver
And then just visit 127.0.0.1:8000/tests/
into your browser
git submodule sync --recursive
git submodule update --init --recursive
./bin/test.sh test
git submodule sync --recursive
git submodule update --init --recursive
./bin/test.sh runserver
## Open browser at http://localhost:8000/tests
git submodule sync --recursive
git submodule update --init --recursive
./bin/example.sh runserver
## Open browser at http://localhost:8000/