我的项目中有以下目录结构:
我正在尝试在我的环境中提供静态文件,但我总是得到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 Static Files Development)静态文件在Dev和生产中以两种不同的方式提供。
有人可以帮帮我吗?
试试这个
os.path.join(BASE_DIR, "finances", "static")