[英]Django static files in Development not working
我的项目中具有以下目录结构:
我试图在我的环境中提供静态文件,但是我总是遇到404错误。
这是我的settings.py配置:
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/2.0/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(BASE_DIR, 'static'),
)
我也将其放在我的urls.py中:
URLS:
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
urlpatterns += staticfiles_urlpatterns()
这是我的观点:
{% load static %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="description" content="">
<meta name="author" content="">
<!-- Favicon icon -->
<link rel="icon" type="image/png" sizes="16x16" href="../assets/images/favicon.png">
<title>Nossas Finanças</title>
<!-- Bootstrap Core CSS -->
<link href="{% static 'plugins/bootstrap/css/bootstrap.min.css' %}" rel="stylesheet">
我已经看了很多教程,但是我不知道我在做什么错。 通过这个问题( Django静态文件开发 ),我知道在Dev和生产环境中,静态文件以两种不同的方式提供。
有人可以帮我吗?
尝试这个
os.path.join(BASE_DIR, "finances", "static")
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.