楷模
image_url = models.ImageField(upload_to="uploads/shows",blank=True,null=True)
我需要将图像上传到特定目录。我正在尝试使用管理面板添加这些媒体文件。如何上传图片?
编辑 1
http://192.168.2.9:8000/static/uploads/shows/myImage.jpg
Page not found (404)
Request Method: GET
Request URL: http://192.168.2.9:8000/static/uploads/shows/myImage.jpg
'uploads/shows/myImage.jpg' could not be found
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
编辑 2
# 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',
)