0
在安裝Photologue之後,在official guide之後,我最初成功地上傳了一個.zip圖庫,但是一旦系統開始給我一個400 BAD REQUEST錯誤,只要我嘗試上傳一個新的.zip畫廊。然而,.zip文件會將其放到我的myapp/media/photologue/temp目錄中,否則不可用。Django Photologue Gallery上傳== Bad請求
該項目是在一個virtualenv。
我的設置文件看起來像
INSTALLED_APPS = (
...
'photologue',
'south',
...
)
MEDIA_ROOT = (
os.path.join(BASE_DIR, 'media')
)
MEDIA_URL = '/media/'
STATIC_URL = '/static/'
STATIC_ROOT = ''
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
from photologue import PHOTOLOGUE_APP_DIR
TEMPLATE_DIRS = (
os.path.join(BASE_DIR, 'templates'),
PHOTOLOGUE_APP_DIR,
)
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader',
)
PHOTOLOGUE_PATH = 'myapp.utils.get_image_path'
Whitin MYAPP/utils.py我有, #MYAPP/utils.py:
import os
def get_image_path(instance, filename):
return os.path.join('path', 'to', 'my', 'files', filename)
而且我用的myapp/urls.py推薦設置as per
#/myapp/urls.py
urlpatterns = patterns('',
...
url(r'^photologue/', include('photologue.urls')),
(r'^i18n/', include('django.conf.urls.i18n')),
url(r'^admin/', include(admin.site.urls)),
)
if settings.DEBUG:
urlpatterns = patterns('',
url(r'^media/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_ROOT, 'show_indexes': True}),
) + urlpatterns
感謝您的期待。