通常情况下,我的问题正好相反!
在我的开发环境中,我的Django应用程序不会加载我的一些静态文件,特别是那些我自己添加的静态文件:也就是说,我添加到我的应用程序中的两个包(admin和ckeditor)都很好地加载,但是我创建和链接自己的两个文件夹(img和css)没有被找到。这是我的目录的地图:
root
|-- blog (this is the name of my app)
|-- mysite (name of my site)
|-- settings.py
|-- urls.py
|-- media
|-- static
|-
我正在使用Django提供的,但是我现在发现jQuery没有被加载,所以管理面板中的可折叠字段集不起作用。这是因为libjs-jquery还没有安装到系统上,但是安装并没有解决这个问题。
Page not found (404)
Request Method: GET
Request URL: http://mysite:8000/static/admin/js/jquery.js
我已经确认/usr/share/pyshared/django/contrib/admin/media/js/jquery.js指向了正确的文件(/usr/share/javascript/jquery/jq
django管理员重定向我无法连接. admin.py
from django.contrib import admin
from .models import *
from django.utils.html import format_html
from django.shortcuts import redirect
class RecommendLaywerAdmin(admin.ModelAdmin):
def sale(request):
return redirect(request, "admin/sale_view.html",
因此,我将Django教程转换为完全使用Apache,而不是使用内置的"runserver“命令。我完成了第一步;让Apache为静态文件(css)提供服务。现在我需要让它为管理员提供静态文件。
到目前为止,我的代码在Apache2.4的httpd.conf文件中。
#static files for site
Alias /static/ "C:/mysite/polls/static/"
<Directory "C:/mysite/polls/static">
Require all granted
</Directory>
伙计们,我是姜戈的纽比..我试图将图片和css等静态文件加载到我的模板中。但是它不起作用..下面是代码
"""
Generated by 'django-admin startproject' using Django 1.8.2.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.
我不知道为什么django不能加载静态文件,即使我已经定义了static_url,static_root,staticfiles_dirs和包括static_root在内的and模式。我将静态文件放在root_dir/ static /目录中。
我的模板也使用了正确的语法{% load static%}和{% static '...'%}
请在这方面给我一些建议。
非常感谢
这是我的主urls文件
from django.contrib import admin
from django.urls import path
from home import views as Hom
我升级到了Django 1.4,现在我的管理静态文件不能加载。
我的设置文件的相关部分如下:
MEDIA_ROOT = os.path.join(SITE_ROOT, 'media')
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = '
我以某种方式让应用程序在django ( python和django的新手)上运行,虽然页面加载了默认URL (127.0.0.1:8000),但它确实加载了css文件。它会产生以下错误:直接访问css文件。
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/static/css/bootstrap.min.css
'css\bootstrap.min.css' could not be found
You're seeing this error because
加载我的CSS文件有困难。我使用的浏览器是Chrome。这是我的代码和文件目录。谢谢!
·电子商务/电子商务/设置服务
import os
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
....
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = T
我已经看过了,但是仍然不知道如何加载css/image文件。
在我的服务器上,图像文件夹和css文件位于/srv/twingle/search
我的urls.py
1 from django.conf.urls.defaults import *
2
3 # Uncomment the next two lines to enable the admin:
4 # from django.contrib import admin
5 # admin.autodiscover()
6
7 urlpatterns = patterns('twingle.sea