Django Admin:上传文件的路径错误。缺少“静态”?

时间:2010-02-26 11:54:29

标签: django django-admin

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

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

我的MEDIA网址在some.url.com/static/和MEDIA ROOT设置为“静态”的绝对路径。

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

我希望能够,在默认的django管理员中,转到订单编辑,将当前上传的文件悬停,点击它,它将在新窗口中打开,显然,目前它是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',
)

1 个答案:

答案 0 :(得分:2)

好吧,我很抱歉打扰你们所有人,但事实证明这是明显的: 我重新启动了fcgi,路径现在正确了。 (duhhh!)

对不起您的麻烦:)