繁体   English   中英

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

[英]How can I set up Debian x86_64 so a Django project sees django.contrib.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

谢谢,

我所看到的是对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)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM