django - Is it possible to have a Procfile and a manage.py file in a different folder level? -


introduction:

  • i following getting started django on heroku quick start guide.

  • i intend apply two scoops of django book philosophy working virtualenvs , projects. audrey roy , daniel greenfeld (authors) put environments in 1 directory , projects in another.

  • i intend apply two scoops of django book philosophy placing generated django-admin.py startproject management command inside directory serves git repository root (a.k.a. three-tiered approach).

the layout @ highest level:

repository_root/     django_project_root/         configuration_root/ 


locally:

os x 10.8.4
pip==1.4.1
virtualenv==1.10.1
virtualenvwrapper==4.1.1
wsgiref==0.1.2
.bashrc contains:

export workon_home=$home/envs export project_home=$home/projects 

~/envs
~/projects


inside hellodjango_venv:

django==1.5.2
dj-database-url==0.2.2
dj-static==0.0.5
django-toolbelt==0.0.1
gunicorn==18.0
psycopg2==2.5.1
static==0.4


from terminal:

mac-pol:~ oubiga$ mkdir -p projects/hellodjango_rep/hellodjango mac-pol:~ oubiga$ cd projects/hellodjango_rep/hellodjango mac-pol:hellodjango oubiga$ mkvirtualenv hellodjango_venv new python executable in hellodjango_venv/bin/python2.7 creating executable in hellodjango_venv/bin/python installing setuptools..................................  ...  ..................................................done. (hellodjango_venv)mac-pol:hellodjango oubiga$ pip install django-toolbelt  ...  installed django-toolbelt django psycopg2 gunicorn dj-database-url dj-static static cleaning up... (hellodjango_venv)mac-pol:hellodjango oubiga$ django-admin.py startproject hellodjango . (hellodjango_venv)mac-pol:hellodjango oubiga$ touch procfile && open procfile 

edit procfile:

web: gunicorn hellodjango.wsgi

start process:

(hellodjango_venv)mac-pol:hellodjango oubiga$ foreman start 01:30:37 web.1  | started pid 638 01:30:37 web.1  | 2013-09-04 01:30:37 [638] [info] starting gunicorn 18.0 01:30:37 web.1  | 2013-09-04 01:30:37 [638] [info] listening at: http://0.0.0.0:5000 (638) 01:30:37 web.1  | 2013-09-04 01:30:37 [638] [info] using worker: sync 01:30:37 web.1  | 2013-09-04 01:30:37 [641] [info] booting worker pid: 641 ctrl+c 

so far, good.

at moment projects tree is:

~/projects/         hellodjango_rep/         hellodjango/ cwd             manage.py             procfile             hellodjango/                 __init__.py                 settings/                 urls.py                 wsgi.py 

and virtualenvs tree is:

~/envs/     get_env_details     initialize     postactivate     postdeactivate     postmkproject     postmkvirtualenv     postrmproject     postrmvirtualenv     preactivate     predeactivate     premkproject     premkvirtualenv     prermproject     prermvirtualenv     hellodjango_venv/         bin/         include/         lib/ 

but, remember three-tiered approach? how can achieve it?

i quite sure hellodjango_rep/ later on contain @ least: .git, .gitignore , requirements.txt


research:

on #django irc channel, jacob kaplan-moss answered:

...the procfile needs @ top-level of git repo...

neil middleton, engineer @ heroku, answered question "procfile declares types -> (none) in heroku" in so:

...your procfile needs in root of git repository pushed heroku...

from heroku dev center:

...process types declared via file named procfile placed in root of app...


as first attempt:

i move procfile 1 folder level.

(hellodjango_venv)mac-pol:hellodjango oubiga$ cd .. 

at moment projects tree is:

~/projects/         hellodjango_rep/ cwd         procfile         hellodjango/             manage.py             hellodjango/                 __init__.py                 settings/                 urls.py                 wsgi.py 

i start process again:

(hellodjango_venv)mac-pol:hellodjango_rep oubiga$ foreman start 

i'll importerror: no module named hellodjango.wsgi


debugging:

the importerror seems come /users/oubiga/envs/hellodjango_venv/lib/python2.7/site-packages/gunicorn/util.py

def import_app(module):     parts = module.split(":", 1)     if len(parts) == 1:         module, obj = module, "application"     else:         module, obj = parts[0], parts[1]      try:         __import__(module)  # <-- line 354     except importerror:         if module.endswith(".py") , os.path.exists(module):             raise importerror("failed find application, did "                 "you mean '%s:%s'?" % (module.rsplit(".", 1)[0], obj))         else:             raise  ... 

no module named hellodjango.wsgi


as second attempt:

procfile comes @ previous level. procfile , manage.py belong again.

(hellodjango_venv)mac-pol:hellodjango_rep oubiga$ foreman start 

i'll error: procfile not exist. it's quite obvious why happens.


hypothesis:

from django documentation:

...manage.py automatically created in each django project. manage.py thin wrapper around django-admin.py takes care of 2 things before delegating django-admin.py:
- puts project’s package on sys.path.
- sets django_settings_module environment variable points project’s settings.py file...

i'm not sure if problem related this.


so:

is possible have procfile , manage.py file in different folder level ?
what wrong approach?


thank in advance.

firstly have say, haven't done wide research , have used heroku 3 times. but:

(your seccond attempt):

procfile should in top level directory. if move procfile deeper gunicorn can't find it.

(your first attempt):

and having procfile on top level directory should state path wsgi. not possible yet. shoud make __init__.py file in first "hellodjango" directory, mark "module". shoud change path in procfile to: hellodjango.hellodjango.wsgi

hope helps.


Comments

Popular posts from this blog

How to remove text and logo OR add Overflow on Android ActionBar using AppCompat on API 8? -

html - How to style widget with post count different than without post count -

url rewriting - How to redirect a http POST with urlrewritefilter -