-
Notifications
You must be signed in to change notification settings - Fork 24
How to create a new integrated application
When the installation is complete, there is a choice either to work on a part of the existing code base, or to create your own isolated application that can be merged into the code base once stable. If you go for the latter, and decide to call your application devilry_component
do following:
-
./src/
- Create the folder structure for your application (remember to replace the name):
- create folder
./src/devilry_component/devilry_component
- create folder
./src/devilry_component/devilry_component/static/
- create folder
./src/devilry_component/devilry_component/templates/
- create folder
- Create the folder structure for your application (remember to replace the name):
-
./src/devilry_component/devilry_component/
(easilly done withtouch
-command)- create
__init__.py
- create
urls.py
- create
models.py
- create
The purpose of this folder structure is to force django to recognize it as a python module and a django application. Later, you can add all necessary files for it to function properly.
The next step is to integrate the application into devilry:
-
./buildout_base.cfg
- Under
[eggs]
adddevilry_component
at the same indent-level as other names - Under
[sources]
devilry_component = fs devilry_component
(fs
prefix tells buildout to fetch the source from the filesystem)
- Under
-
./devenv/settings/default_settings.py
- add
devilry_component
toINSTALLED_APPS
- add
-
./devenv/settings/deafult_urls.py
- make
(r'^devilry_component/', include('devilry_component.urls'))
, a part of the tupledevilry_urls
. (don't forget the comma after the last element!)
- make
When the last step is complete, your application will be a formal component of devilry
.
-
./devenv/
- run
./bin/buildout
-command - if you have added the models to model
models.py
: rundjango_dev.py syncdb
- if you have added static files:
run
django_dev.py collectstatic -l
(drop the-l
-parameter on windows)
- run
-
Run
./devenv/bin/django_dev.py runserver
Your application is live on http://localhost:8000/devilry_component/
Set up a minimal version of urls.py
for your application:
- ./src/devilry_component/devilry_component/urls.py
- ./src/devilry_componen/setup.py
- ./src/devilry_componen/README.rst
# -*- coding: utf-8 -*-
from django.conf.urls.defaults import patterns, include, url
from django.contrib.auth.decorators import login_required
from django.views.i18n import javascript_catalog
from django.views.decorators.csrf import csrf_protect, ensure_csrf_cookie
from devilry_settings.i18n import get_javascript_catalog_packages
from .views import AppView
i18n_packages = get_javascript_catalog_packages(
'devilry_stats', 'devilry_header', 'devilry_extjsextras', 'devilry.apps.core'
)
@login_required
def emptyview(request):
from django.http import HttpResponse
return HttpResponse('Logged in')
urlpatterns = patterns('devilry_stats',
url('^emptytestview', emptyview), # NOTE: Only used for testing
)
Move onto developing your ReST API or the Ext.js part of the application in the static
-folder and don't forget to check the errors in the javascript console!