Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/delphi/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python Apache django未在表单中保存带有图像字段的图像_Python_Django_Apache_Image Uploading - Fatal编程技术网

Python Apache django未在表单中保存带有图像字段的图像

Python Apache django未在表单中保存带有图像字段的图像,python,django,apache,image-uploading,Python,Django,Apache,Image Uploading,我有一个表单,如果我不添加任何图像,它可以正常工作,但如果我尝试上载图像,它会根据apache日志给出模板未找到错误。这里的问题是,我的带有图像的表单在本地服务器(django)上运行良好,但在启动apache并在其中运行项目时没有上载图像 这是我的.conf文件 <VirtualHost *:80> WSGIScriptAlias / /home/anmol/suvidha.wsgi ServerName suvidha.com Alias /static /var/www/su

我有一个表单,如果我不添加任何图像,它可以正常工作,但如果我尝试上载图像,它会根据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>
我的.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

如果有人能帮上忙,那就太好了,我被困在这个问题上,找不到任何答案。

这告诉你的是,图像上传在某个地方触发了异常,这通常会导致500个错误响应,但你没有500.html模板来显示响应。创建相关的模板,您将能够看到真正的bug

[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