如果我没有添加任何图片,我有一个正常工作的表单,但如果我尝试上传图片,则根据apache日志提供模板未找到错误。这里的问题是我的图像表单在我的本地服务器(django)上工作正常,但是当我启动apache并在其中运行项目时没有上传图像。
这是我的.conf文件
<VirtualHost *:80>
WSGIScriptAlias / /home/anmol/suvidha.wsgi
ServerName suvidha.com
Alias /static /var/www/suvidha/register/static/
<Directory /var/www/suvidha/>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
我的.wsgi文件
import os
import sys
sys.path = ['/var/www/suvidha'] + sys.path
os.environ['DJANGO_SETTINGS_MODULE'] = 'suvidha.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
我的.settings文件
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = join(BASE_DIR, 'register/static')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '/static/images/'
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
#'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
我的目录列表
/var
/www
/suvidha
/register
/static
日志文件
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] mod_wsgi (pid=15679):Exception occurred processing WSGI script '/home/byld/suvidha.wsgi'.
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] Traceback (most recent call last):
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 241, in __call__
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] response = self.get_response(request)
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 153, in get_response
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 228, in handle_uncaught_exception
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] return callback(request, **param_dict)
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] File "/usr/local/lib/python2.7/dist-packages/django/utils/decorators.py", line 91, in _wrapped_view
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] response = view_func(request, *args, **kwargs)
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] File "/usr/local/lib/python2.7/dist-packages/django/views/defaults.py", line 32, in server_error
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] t = loader.get_template(template_name) # You need to create a 500.html template.
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py", line 145, in get_template
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] template, origin = find_template(template_name)
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] File "/usr/local/lib/python2.7/dist-packages/django/template/loader.py", line 138, in find_template
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] raise TemplateDoesNotExist(name)
[Tue Apr 22 00:23:53 2014] [error] [client 192.168.58.196] TemplateDoesNotExist: 500.html
如果有人可以提供帮助,那就太棒了,我坚持这个并且无法找到答案。
答案 0 :(得分:0)
这告诉你的是,你有一个由图片上传触发的异常,这通常会导致500错误响应 - 但你没有用于显示响应的500.html模板。创建相关模板,您将能够看到真正的错误。