Django packaging project with multiple applications
I am trying to package my Django project with no success. My project looks like this:
dsbg/
manage.py
dsbg/
__init__.py
urls.py
wsgi.py
app1/
__init__.py
models.py
views.py
urls.py
app2/
__init__.py
models.py
views.py
urls.py
settings/
base.py
local.py
prod.py
static/
app1/
images/
background.gif
style.css
templates/
home.html
app1/
detail.html
index.html
app2/
detail.html
index.html
I followed the procedure here , but I'm not sure if I'm doing the right thing (their example only has one application: polls), I did the following:
- move apps + static + directory templates to new django-dsbg directory (save dsbg and settings in root directory)
- in django-dsbg, create a setup.py file with package files (app1 and app2) and create MANIFEST.in to include static and template directories.
-
in django-dsbg, run:
python setup.py sdist
-
in the parent django-dsbg directory, run:
pip install --user django-dsbg/dist/django-dsbg-0.1.tar.gz
After that, the project looks like this:
dsbg/
manage.py
settings/
base.py
local.py
prod.py
dsbg/
__init__.py
urls.py
wsgi.py
django-dsbg/
LICENSE
MANIFEST.in
README.rst
app1/
models.py
views.py
urls.py
app2/
models.py
views.py
urls.py
templates/
home.html
app1/
...
app2/
...
static/
...
Now in the root directory (top dsbg) I try to start the server:
python manage.py runserver --settings=settings.local
The server works well, but when pointing to localhost, the browser says:
TemplateDoesNotExist at / home.html.
...
Python Path: ['/home/patrick/django/dsbg/dsbg',
...
'/home/patrick/.local/lib/python2.7/site-packages']
This home.html file is located in django-dsbg / templates. Neither dsbg / dsbg nor .local / lib / python2.7 / site-packages contain home.html. The latter contains all my apps, but not the static or template directory.
What am I doing wrong? Can anyone help me? Any help is appreciated. Patrick
You need the absolute path to the templates, no matter where the applications are located, you can always just
TEMPLATES_DIRS = ('/home/user/dsbg/django-dsbg/templates', )
or
# Django 1.8 +
Dirs = ['templates']