如何设置Debian x86_64以便Django项目看到django.contrib.staticfiles?

时间:2014-04-23 23:00:46

标签: python django debian web-deployment django-staticfiles

我有一个新的Debian VPS,我尝试部署的Django项目没有看到django.contrib.staticfiles。*。做一个" pip install django-staticfiles"没有明显改变的事情。

让这些Django项目运行得足够好的最佳方法是什么?

- 编辑 -

我尝试卸载Django,然后使用pip和virtualenv安装。这导致另一个错误,无法导入execute_manager。终端输出是:

Proceed (y/n)? y
  Successfully uninstalled gunicorn
root@ps306627:/home/cjsh/pragmatometer# exit
(pragmatometerenvironment)cjsh@ps306627:~/pragmatometer$ pip uninstall django
Uninstalling Django:
  /home/cjsh/pragmatometerenvironment/bin/django-admin.py
  /home/cjsh/pragmatometerenvironment/lib/python2.6/site-packages/Django-1.6.3-py2.6.egg-info
  /home/cjsh/pragmatometerenvironment/lib/python2.6/site-packages/django
Proceed (y/n)? y
  Successfully uninstalled Django
(pragmatometerenvironment)cjsh@ps306627:~/pragmatometer$ pip install django
Downloading/unpacking django
  Downloading Django-1.6.3.tar.gz (6.6Mb): 6.6Mb downloaded
  Running setup.py egg_info for package django
    warning: no previously-included files matching '__pycache__' found under directory '*'
    warning: no previously-included files matching '*.py[co]' found under directory '*'
Installing collected packages: django
  Running setup.py install for django
    changing mode of build/scripts-2.6/django-admin.py from 644 to 755
    warning: no previously-included files matching '__pycache__' found under directory '*'
    warning: no previously-included files matching '*.py[co]' found under directory '*'
    changing mode of /home/cjsh/pragmatometerenvironment/bin/django-admin.py to 755
Successfully installed django
Cleaning up...
(pragmatometerenvironment)cjsh@ps306627:~/pragmatometer$ pip install gunicorn
Downloading/unpacking gunicorn
  Downloading gunicorn-18.0.tar.gz (366Kb): 366Kb downloaded
  Running setup.py egg_info for package gunicorn
    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
    warning: no previously-included files matching '*.pyc' found under directory 'tests'
    warning: no previously-included files matching '*.pyo' found under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory 'examples'
    warning: no previously-included files matching '*.pyo' found under directory 'examples'
Installing collected packages: gunicorn
  Running setup.py install for gunicorn
    warning: no previously-included files matching '*.pyc' found under directory 'docs'
    warning: no previously-included files matching '*.pyo' found under directory 'docs'
    warning: no previously-included files matching '*.pyc' found under directory 'tests'
    warning: no previously-included files matching '*.pyo' found under directory 'tests'
    warning: no previously-included files matching '*.pyc' found under directory 'examples'
    warning: no previously-included files matching '*.pyo' found under directory 'examples'
    Installing gunicorn_paster script to /home/cjsh/pragmatometerenvironment/bin
    Installing gunicorn script to /home/cjsh/pragmatometerenvironment/bin
    Installing gunicorn_django script to /home/cjsh/pragmatometerenvironment/bin
Successfully installed gunicorn
Cleaning up...
(pragmatometerenvironment)cjsh@ps306627:~/pragmatometer$ python manage.py runserver
Traceback (most recent call last):
  File "manage.py", line 2, in <module>
    from django.core.management import execute_manager
ImportError: cannot import name execute_manager

谢谢,

1 个答案:

答案 0 :(得分:0)

我看到的是一个manage.py的烦恼,它与系统运行的较新版本的python不同步。

新的,有效的manage.py,旧的注释,是:

#!/usr/bin/env python
import os, sys

if __name__ == "__main__":
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pragmatometer.settings")
    from django.core.management import execute_from_command_line
    execute_from_command_line(sys.argv)
##!/usr/bin/env python
#from django.core.management import execute_manager
#import imp
#try:
#    imp.find_module('settings') # Assumed to be in the same directory.
#except ImportError:
#    import sys
#    sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n" % __file__)
#    sys.exit(1)
#
#import settings
#
#if __name__ == "__main__":
#    execute_manager(settings)