Introduzione:
sto seguendo la guida rapida Getting Started with Django on Heroku.È possibile avere un file Proc e un file manage.py in un diverso livello di cartella?
Ho intenzione di applicare il due palette di Django filosofia libro su come lavorare con virtualenvs e progetti. Audrey Roy e Daniel Greenfeld (autori) piace mettere tutti gli ambienti in una directory e tutti i progetti in un'altra.
ho anche intenzione di applicare le due palline di Django libro di filosofia su come piazzare ciò che viene generato dal comando
django-admin.py startproject
gestione all'interno di un altro indice che serve come radice repository git (aka tre livelli approccio) .
La disposizione al più alto livello:
repository_root/
django_project_root/
configuration_root/
A livello locale:
OS X 10.8.4
pip == 1.4.1
virtualenv == 1.10.1
virtualenvwrapper == 4.1.1
wsgiref == 0.1.2
.bashrc contiene:
export WORKON_HOME=$HOME/Envs
export PROJECT_HOME=$HOME/Projects
~/ENV
~/Progetti
All'interno hellodjango_venv:
D jango == 1.5.2
dj-Database-url == 0.2.2
dj-statico == 0.0.5
django-toolbelt == 0.0.1
gunicorn == 18,0
psycopg2 == 2.5 .1
statico == 0.4
Dal 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
Also creating executable in hellodjango_venv/bin/python
Installing Setuptools..................................
...
..................................................done.
(hellodjango_venv)mac-pol:hellodjango oubiga$ pip install django-toolbelt
...
Successfully 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
Avviare il processo:
(hellodjango_venv)mac-pol:hellodjango oubiga$ foreman start
01:30:37 web.1 | started with 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 with pid: 641
CTRL+C
Finora, tutto bene.
Al momento i miei progetti Tree è:
~/Projects/
hellodjango_rep/
hellodjango/ cwd
manage.py
Procfile
hellodjango/
__init__.py
settings/
urls.py
wsgi.py
e il mio albero Virtualenvs è:
~/Envs/
get_env_details
initialize
postactivate
postdeactivate
postmkproject
postmkvirtualenv
postrmproject
postrmvirtualenv
preactivate
predeactivate
premkproject
premkvirtualenv
prermproject
prermvirtualenv
hellodjango_venv/
bin/
include/
lib/
Ma, vi ricordate l'approccio a tre livelli ? Come posso ottenerlo?
Sono abbastanza sicuro hellodjango_rep/in seguito conterrà almeno: .git, .gitignore e requirements.txt
di ricerca:
Sul IRC#django canale, Jacob Kaplan-Moss ha risposto:
... il Procfile ha bisogno di essere al livello superiore del vostro repo git ...
Neil Middleton, Engineer presso Heroku, ha risposto a questa domanda "Procfile dichiara i tipi -> (nessuno) in Heroku" in SO:
... il tuo Procfile ha bisogno di essere nella root della vostra repository git che viene spinto a Heroku ...
da Heroku Dev Center:
... tipi di processo sono dichiarati tramite un file chiamato Procfile collocato nella radice della vostra applicazione ...
come un primo tentativo:
Sposto Procfile su un livello di cartella.
(hellodjango_venv)mac-pol:hellodjango oubiga$ cd ..
Al momento il mio Progetti albero è:
~/Projects/
hellodjango_rep/ cwd
Procfile
hellodjango/
manage.py
hellodjango/
__init__.py
settings/
urls.py
wsgi.py
comincio di nuovo il processo:
(hellodjango_venv)mac-pol:hellodjango_rep oubiga$ foreman start
Prendo ImportError: No module named hellodjango.wsgi
Debug:
L'ImportError sembra provenire da /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") and os.path.exists(module):
raise ImportError("Failed to find application, did "
"you mean '%s:%s'?" % (module.rsplit(".", 1)[0], obj))
else:
raise
...
No module named hellodjango.wsgi
Come un secondo tentativo:
Procfile ritorna al livello precedente. Procfile e manage.py appartengono di nuovo insieme.
(hellodjango_venv)mac-pol:hellodjango_rep oubiga$ foreman start
Prendo ERROR: Procfile does not exist.
E 'abbastanza ovvio perché succede.
Ipotesi:
Da documentazione Django:
... manage.py viene creato automaticamente in ogni progetto Django. manage.py è un sottile involucro attorno a django-admin.py che si prende cura di due cose per te prima di delegare a django-admin.py:
- Mette il pacchetto del tuo progetto su sys.path.
- Si imposta la variabile d'ambiente DJANGO_SETTINGS_MODULE in modo che punti al file di settings.py del progetto ...
io non sono sicuro se il problema è legato a questo.
Quindi:
E 'possibile avere un Procfile e un file manage.py nel livello di cartella diversa?
Cosa c'è di sbagliato in questo approccio?
Grazie in anticipo.
So che è troppo tardi. Non è necessario modificare nulla. Metti il 'procfile' al massimo livello. ed esegui 'gunicorn --chdir hellodjango hellodjango.wsgi'. Funzionerà. Grazie – Shah