我是django和夹层的新手,我为我的django peoject设置了夹层。 但是当我加载管理员登录页面时,我得到这是我的服务器日志这些文件应该加载,但我从那里得到301或404响应代码。
[14/Apr/2014 10:23:12] "GET /static/mezzanine/js/jquery-1.7.1.min.js HTTP/1.1" 301 0
[14/Apr/2014 10:23:12] "GET /static/mezzanine/css/admin/global.css HTTP/1.1" 301 0
[14/Apr/2014 10:23:12] "GET /static/mezzanine/js/admin/login.js HTTP/1.1" 301 0
[14/Apr/2014 10:23:12] "GET /static/mezzanine/css/admin/global.css/ HTTP/1.1" 404 112
[14/Apr/2014 10:23:12] "GET /static/mezzanine/js/admin/login.js/ HTTP/1.1" 404 109
[14/Apr/2014 10:23:12] "GET /static/mezzanine/js/jquery-1.7.1.min.js/ HTTP/1.1" 404 114
附上屏幕截图。
这是我的设置文件: import os
#=====================#
# DJANGO #
#=====================#
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
ADMINS = (
# ('Your Name', 'your_email@domain.com'),
)
MANAGERS = ADMINS
TIME_ZONE = 'UTC'
USE_TZ = True
LANGUAGE_CODE = 'en-us'
DEBUG = True
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
SITE_ID=1
USE_I18N = True
SECRET_KEY = '!0nlw*q%l(m6xovqy2m4&*qo6&g*!09007*9!qr0#4j#ex-ndk'
INTERNAL_IPS = ("127.0.0.1",)
ALLOWED_HOSTS = ['localhost']
WSGI_APPLICATION = "mysite.wsgi.application"
TEMPLATE_LOADERS = (
"django.template.loaders.filesystem.Loader",
"django.template.loaders.app_directories.Loader",
)
AUTHENTICATION_BACKENDS = ("mezzanine.core.auth_backends.MezzanineBackend",)
STATICFILES_FINDERS = (
"django.contrib.staticfiles.finders.FileSystemFinder",
"django.contrib.staticfiles.finders.AppDirectoriesFinder",
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
}
}
#=====================#
#PATH
#=====================#
PROJECT_ROOT = os.path.dirname(os.path.abspath(__file__))
PROJECT_DIRNAME = PROJECT_ROOT.split(os.sep)[-1]
CACHE_MIDDLEWARE_KEY_PREFIX = PROJECT_DIRNAME
FILE_UPLOAD_PERMISSIONS = 0o644
STATIC_URL = "/static/"
STATIC_ROOT = os.path.join(PROJECT_ROOT, STATIC_URL.strip("/"))
COMPRESS_ROOT = STATIC_ROOT
MEDIA_URL = STATIC_URL + "media/"
MEDIA_ROOT = os.path.join(PROJECT_ROOT, *MEDIA_URL.strip("/").split("/"))
ADMIN_MEDIA_PREFIX = STATIC_URL + "grappelli/"
ROOT_URLCONF = "%s.urls" % PROJECT_DIRNAME
TEMPLATE_DIRS = (os.path.join(PROJECT_ROOT, "templates"),)
# FIXTURE_DIRS = PROJECT_ROOT.child("fixtures")
#=====================#
# APPLICATIONS #
#=====================#
INSTALLED_APPS = (
# "djnaog_toolbar",
# "django_extensions",
"django.contrib.admin",
"django.contrib.auth",
"django.contrib.contenttypes",
"django.contrib.redirects",
"django.contrib.sessions",
"django.contrib.sites",
"django.contrib.sitemaps",
"django.contrib.staticfiles",
"mezzanine.boot",
"mezzanine.conf",
"mezzanine.core",
"mezzanine.generic",
"mezzanine.blog",
"mezzanine.forms",
"mezzanine.pages",
"mezzanine.galleries",
"mezzanine.twitter",
'youtube',
"south"
# 'filebrowser_safe',
)
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.contrib.messages.context_processors.messages",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.static",
"django.core.context_processors.media",
"django.core.context_processors.request",
"django.core.context_processors.tz",
"mezzanine.conf.context_processors.settings",
)
MIDDLEWARE_CLASSES = (
"mezzanine.core.middleware.UpdateCacheMiddleware",
"django.contrib.sessions.middleware.SessionMiddleware",
"django.middleware.locale.LocaleMiddleware",
"django.contrib.auth.middleware.AuthenticationMiddleware",
"django.middleware.common.CommonMiddleware",
"django.middleware.csrf.CsrfViewMiddleware",
"django.contrib.messages.middleware.MessageMiddleware",
"mezzanine.core.request.CurrentRequestMiddleware",
"mezzanine.core.middleware.RedirectFallbackMiddleware",
"mezzanine.core.middleware.TemplateForDeviceMiddleware",
"mezzanine.core.middleware.TemplateForHostMiddleware",
"mezzanine.core.middleware.AdminLoginInterfaceSelectorMiddleware",
"mezzanine.core.middleware.SitePermissionMiddleware",
# Uncomment the following if using any of the SSL settings:
# "mezzanine.core.middleware.SSLRedirectMiddleware",
"mezzanine.pages.middleware.PageMiddleware",
"mezzanine.core.middleware.FetchFromCacheMiddleware",
)
PACKAGE_NAME_FILEBROWSER = "filebrowser_safe"
PACKAGE_NAME_GRAPPELLI = "grappelli_safe"
OPTIONAL_APP={
"debug_toolbar",
"django_extensions",
"compressor",
PACKAGE_NAME_FILEBROWSER,
PACKAGE_NAME_GRAPPELLI,
}
#=====================#
# MEZZANINE
#=====================#
ADMIN_MENU_ORDER = (
("Content", (("Media Library", "fb_browse"),)),
("Users", ("auth.User", "auth.Group",)),
("Site", ("sites.Site", "redirects.Redirect", "conf.Setting")),
)
DASHBOARD_TAGS = (
("mezzanine_tags.app_list",),
("comment_tags.recent_comments",),
("mezzanine_tags.recent_actions",),
)
BLOG_USE_FEATURED_IMAGE = True
USE_SOUTH = True
GEOPOSITION_DEFAULT_ZOOM = 5
GEOPOSITION_DEFAULT_CENTRE = (21.77, 78.87,)
DEVICE_USER_AGENTS = (
("mobile", ("Android", "BlackBerry", "iPhone", "Windows Phone")),
("desktop", ("Windows", "Macintosh", "Linux")),
)
# RICHTEXT_WIDGET_CLASS = 'pari.article.forms.TinyMceWidget'
#
# RICHTEXT_FILTERS = (
# 'pari.article.rich_text_filter.article_content_filter',
# )
FORMS_USE_HTML5 = True
ACCOUNTS_VERIFICATION_REQUIRED = True
SSL_FORCE_URL_PREFIXES = ("/admin", "/account", "/asset_proxy")
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTOCOL', 'https')
SEARCH_MODEL_CHOICES = (
"pages.Page",
"youtube.Youtube",
)
try:
from local_settings import *
except ImportError:
pass
try:
from mezzanine.utils.conf import set_dynamic_settings
except ImportError:
pass
else:
set_dynamic_settings(globals())
from django.conf.urls import patterns, include, url
from django.contrib import admin
from mezzanine.core.views import direct_to_template
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
url(r'^$', 'youtube.views.upload'),
url(r'^uploaded','youtube.views.uploaded'),
# url(r'^$', 'youtube.views.root'),
# url(r'^upload','youtube.views.upload'),
# url(r'^blog/', include('blog.urls')),
# url(r'^admin/filebrowser/',include(site.urls)),
url(r'^grappeli/',include('grappelli.urls')),
url(r'^admin/', include(admin.site.urls)),
url("^$", direct_to_template, {"template": "index.html"}, name="home"),
url("^$", "mezzanine.pages.views.page", {"slug": "/"}, name="home"),
("^", include("mezzanine.urls")),
("^", include("filebrowser_safe.urls")),
)
handler404 = "mezzanine.core.views.page_not_found"
handler500 = "mezzanine.core.views.server_error"
以下是我期望的内容以及我在django项目中获得的截图:
预期的登录和仪表板屏幕:
实际登录屏幕和点击媒体库图标后的错误:
答案 0 :(得分:0)
您遵循了哪些安装步骤? install steps in the documentation对我来说很好:
pip install south pillow django-compressor
pip install mezzanine
mezzanine-project test_project
cd test_project
python manage.py createdb --noinput
python manage.py runserver
答案 1 :(得分:0)
您期望的屏幕截图显示了Django管理员的Grappelli皮肤。
对于你想要的夹层
pip install grappelli-safe
答案 2 :(得分:0)
一切看起来都正常......
您的屏幕截图显示您要
<强>本地主机:8000 /浏览/ 强>
在你的urls.py中没有提及browse /
在浏览器中,您需要转到:
<强>本地主机:8000 强>
或管理员:
<强>本地主机:8000 /管理/ 强>
如果你想看到任何内容。