簡體   English   中英

開發中的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中:

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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM