gpt4 book ai didi

Django 管理员 : Path to file uploaded is wrong. 缺少 "static"吗?

转载 作者:行者123 更新时间:2023-12-02 02:04:11 26 4
gpt4 key购买 nike

我有一个简单的模型和 django 中的默认管理员。一切都按预期进行,我可以上传文件。我已经阅读了有关上传路径的 django 文档。我的媒体 URL 和媒体根已设置并且上传工作正常。假设我登录到默认管理员,使用上传的 jpg 下订单,然后我去编辑订单,然后看到当前上传的文件。

如果我将鼠标悬停在当前文件链接上,完整的网址是 some.url.com/uploads/myfile.jpg,而它应该是 some.url.com/static/uploads/myfile.jpg ???

我的媒体 URL 设置为 some.url.com/static/,媒体根设置为“static”的绝对路径。

由于上传工作正常并到达应有的位置,因此可能缺少某些内容...

我希望能够在默认的 django admin 内转到订单编辑,将鼠标悬停在当前上传的文件上,单击它,它将在新窗口中打开,显然,目前它是 404...

模型中的相关部分:

ficheiro = models.FileField(upload_to='uploads')

这是截图: screenshot http://anibalcascais.com/exemplo.jpg

谢谢

# Django settings for ensanis project.
import os.path


DEBUG = False
TEMPLATE_DEBUG = DEBUG

ADMINS = (
# ('Anibal Santos', 'anibalcascais@gmail.com'),
)

MANAGERS = ADMINS

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'Europe/Lisbon'

# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'pt_PT'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True

# Absolute path to the directory that holds media.
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = '/home/anibal/sites/ensanis/static/'

# 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", "http://example.com/media/"
MEDIA_URL = 'http://cl10.anibalcascais.com/static/'

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = 'http://cl10.anibalcascais.com/media/'



# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
# 'django.template.loaders.eggs.load_template_source',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
)

ROOT_URLCONF = 'ensanis.urls'

TEMPLATE_DIRS = (
'templates',
)



INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'ensanis.encomendas',
'django.contrib.admin',
'ensanis.django_evolution',
)

最佳答案

好吧,很抱歉打扰大家,但事实证明这是显而易见的事情:我已经重新启动了 fcgi,路径现在是正确的。 (呃!)

很抱歉给您带来麻烦:)

关于Django 管理员 : Path to file uploaded is wrong. 缺少 "static"吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2341351/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com