我将移至Django 1.3,发现媒体和静态文件的这种分离有点令人困惑。这是默认settings.py
的样子:
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''
# 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/media/", "http://example.com/media/"
MEDIA_URL = ''
# Absolute path to the directory that holds static files.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
# URL that handles the static files served from STATIC_ROOT.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
我应该在
MEDIA_ROOT
和STATIC_ROOT
中放入什么?这些应该是单独的目录吗?有什么区别? 最佳答案
静态文件用于javascript/图像等,而媒体文件用于用户上传的内容。
关于python - Django中的静态文件和媒体文件有什么区别?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/5016589/