【发布时间】:2021-02-01 12:51:01
【问题描述】:
我是 Django 新手,我遇到了加载静态文件(图像)的问题。我得到了
127.0.0.1/:1707 GET http://127.0.0.1:8000/static/css/static/images/background/1.jpg 404 (Not Found)
我很确定问题出在路径上,但我不明白这个 /static/css/ 来自哪里。你能帮帮我吗?
我的 settings.py 文件:
STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'evillio/static')
]
我的 index.html 文件:
<!-- First Page with Picture and Search Starts -->
<section class="home-one home1-overlay **home1_bgi1**">
<div class="container">
<div class="row posr">
<div class="col-lg-12">
<div class="home_content">
<div class="home-text text-center">
<h2 class="fz55">Find Your Dream Home</h2>
<p class="fz18 color-white">From as low as $10 per day with limited time offer discounts.</p>
</div>
我的 CSS 文件:
home1_bgi1{
background-image: url('static/images/background/1.jpg');
-webkit-background-size: cover;
background-size: cover;
background-position: center center;
height: 960px;
检查页面时
【问题讨论】:
标签: html css django django-templates