开发中的 Django 静态文件不起作用

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:

网址:

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) 知道静态文件在开发和生产中以两种不同的方式提供。

有人可以帮助我吗?

试试这个

os.path.join(BASE_DIR, "finances", "static")

对于使用 Windows 遇到此问题的其他人 ,请记住您可能需要重新启动开发服务器(“.manage runserver”命令)添加新的静态文件后。