python3 django 静态html 中文乱码_python django - 页面未找到错误(404) - 静态错误...

I somehow got the application running on django (new to python and django) and although the page loads the default URL (127.0.0.1:8000) but it does load the css files. It produces following error css files are directly accessed.

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 you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

Here is my settings.py page:

STATIC_URL = '/static/'

# Template location

TEMPLATE_DIRS = {

os.path.join(os.path.dirname(BASE_DIR), "whattheheck", "static", "templates"),

}

if DEBUG:

MEDIA_URL = '/media/'

STATIC_ROOT = os.path.join(os.path.dirname(BASE_DIR), "whattheheck", "static", "static-only")

MEDIA_ROOT = os.path.join(os.path.dirname(BASE_DIR), "whattheheck", "static", "media")

STATICFLIES_DIRS = (

os.path.join(os.path.dirname(BASE_DIR), "whattheheck", "static", "static")

)

and Here is the urls.py page:

from django.conf.urls import patterns, include, url

from django.conf import settings

from django.conf.urls.static import static

from django.contrib import admin

admin.autodiscover()

urlpatterns = patterns('',

# Examples:

url(r'^$', 'signups.views.home', name='home'),

# url(r'^blog/', include('blog.urls')),

url(r'^admin/', include(admin.site.urls)),

)

if settings.DEBUG:

urlpatterns += static(settings.STATIC_URL,

document_root=settings.STATIC_ROOT)

urlpatterns += static(settings.MEDIA_URL,

document_root=settings.MEDIA_ROOT)

can someone help with this please?

解决方案

After you add any kind of static files to your project you should execute

python manage.py collectstatic

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值