我做了一個自動升級(Debian的規則,但有時踢...)的Django的,現在我不能讓我的應用程序的管理部分...Django的1.3-> 1.4.6 staticfiles
登錄(正確與否)後,調試顯示
ImproperlyConfigured at /admin/
You're using the staticfiles app without having set the required STATIC_URL setting.
Request Method: POST
Request URL: http://django.zzzz.yy:83/wwwwwwww/admin/
Django Version: 1.4.5
Exception Type: ImproperlyConfigured
Exception Value:
You're using the staticfiles app without having set the required STATIC_URL setting.
Exception Location: /usr/lib/python2.7/dist-packages/django/contrib/staticfiles/utils.py in check_settings, line 49
Python Executable: /usr/bin/python
Python Version: 2.7.3
Python Path:
['/home',
'/home/wwwwwwww',
'/usr/lib/python2.7',
'/usr/lib/python2.7/plat-linux2',
'/usr/lib/python2.7/lib-tk',
'/usr/lib/python2.7/lib-old',
'/usr/lib/python2.7/lib-dynload',
'/usr/local/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages',
'/usr/lib/python2.7/dist-packages/PIL',
'/usr/lib/pymodules/python2.7']
我讀了很多明智的教程,所以我知道,這個問題是這1.4是新的靜態文件,但我definetely不明白是什麼爲和(這對我來說更重要)如何修復它..
the settings.py:
(...)
# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/home/media/'
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash if there is a path component (optional in other cases).
# Examples: "http://media.lawrence.com", "http://example.com/media/"
MEDIA_URL = ''
# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = '/static/'
STATIC_ROOT = "/var/www/static/"
STATIC_URL = "/static/"
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'django.contrib.staticfiles',
'accounts',
)
(...)
和Apache設置:
Alias /admin_media/ /usr/share/pyshared/django/contrib/admin/media/
當我創造的應用程序(在1.3)我創建教程應用程序,不要添加任何CSS或圖像 - >只是純粹的應用程序 - 我使用管理員來編輯對象(這是非常早的版本 - 沒有界面 - 只是視圖)。
我的應用程序是在/ home:
/家庭/ APP1 /家庭/ APP 2 /家庭/ APP3
(這些應用程序是完全獨立的)
據我瞭解靜態文件對於Django的應用常見(如管理員的的CSS是一樣的所有的應用程序)
所以問題:
- 我應該在哪裏粘貼常用文件(以及它們現在的位置?
- 應該改變什麼設置?
- 我應該在哪裏粘貼CSS專門給各應用(在將來,當我出門很發展,並轉到 搶鮮; d
是否使用1.4只是因爲這是版本Debian使用? – fcoelho
是的。最高穩定性 –
如果您沒有任何其他限制,請考慮在[virtualenv](http://www.virtualenv.org/en/ latestst /)中開發您的項目。你將能夠使用最新的Django版本,而不會修改你的系統範圍的版本 – fcoelho