Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/23.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
django 2.0中的404静态文件错误_Django_Python 3.x_Django Templates - Fatal编程技术网

django 2.0中的404静态文件错误

django 2.0中的404静态文件错误,django,python-3.x,django-templates,Django,Python 3.x,Django Templates,我正在尝试在django 2.0中查找所有静态文件。但是当我只运行服务器时,我得到了404个错误 [11/Feb/2018 00:45:11] "GET /static/bower_components/bootstrap/css/bootstrap.min.css HTTP/1.1" 404 1869 [11/Feb/2018 00:45:11] "GET /static/internal/css/general.css HTTP/1.1" 404 1797 [11/Feb/2018 00:4

我正在尝试在django 2.0中查找所有静态文件。但是当我只运行服务器时,我得到了404个错误

[11/Feb/2018 00:45:11] "GET /static/bower_components/bootstrap/css/bootstrap.min.css HTTP/1.1" 404 1869
[11/Feb/2018 00:45:11] "GET /static/internal/css/general.css HTTP/1.1" 404 1797
[11/Feb/2018 00:45:11] "GET /static/internal/css/AdminLTE.min.css HTTP/1.1" 404 1812
[11/Feb/2018 00:45:11] "GET /static/internal/css/skins/all-skins.min.css HTTP/1.1" 404 1833
[11/Feb/2018 00:45:11] "GET /static/internal/js/adminlte.min.js HTTP/1.1" 404 1806
[11/Feb/2018 00:45:11] "GET /static/bower_components/jquery/internal/jquery.min.js HTTP/1.1" 404 1863
[11/Feb/2018 00:45:11] "GET /static/bower_components/bootstrap/internal/js/bootstrap.min.js HTTP/1.1" 404 1890
[11/Feb/2018 00:45:11] "GET /static/bower_components/bootstrap/css/bootstrap.min.css HTTP/1.1" 404 1869
[11/Feb/2018 00:45:11] "GET /static/internal/css/AdminLTE.min.css HTTP/1.1" 404 1812
[11/Feb/2018 00:45:11] "GET /static/internal/css/general.css HTTP/1.1" 404 1797
[11/Feb/2018 00:45:11] "GET /static/internal/css/skins/all-skins.min.css HTTP/1.1" 404 1833
[11/Feb/2018 00:45:11] "GET /static/bower_components/jquery/internal/jquery.min.js HTTP/1.1" 404 1863
[11/Feb/2018 00:45:11] "GET /static/bower_components/bootstrap/internal/js/bootstrap.min.js HTTP/1.1" 404 1890
这是我的设置代码

STATIC_URL = '/static/'
STATIC_ROOT = '/var/www/example.com/static/'

STATICFILES_DIRS = (
    os.path.join(BASE_DIR, "static"),
)
还有我的url代码

urlpatterns = [
    path('admin/', admin.site.urls),
    path('', include('naturalUser.urls'))
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
404错误

[11/Feb/2018 00:45:11] "GET /static/bower_components/bootstrap/css/bootstrap.min.css HTTP/1.1" 404 1869
[11/Feb/2018 00:45:11] "GET /static/internal/css/general.css HTTP/1.1" 404 1797
[11/Feb/2018 00:45:11] "GET /static/internal/css/AdminLTE.min.css HTTP/1.1" 404 1812
[11/Feb/2018 00:45:11] "GET /static/internal/css/skins/all-skins.min.css HTTP/1.1" 404 1833
[11/Feb/2018 00:45:11] "GET /static/internal/js/adminlte.min.js HTTP/1.1" 404 1806
[11/Feb/2018 00:45:11] "GET /static/bower_components/jquery/internal/jquery.min.js HTTP/1.1" 404 1863
[11/Feb/2018 00:45:11] "GET /static/bower_components/bootstrap/internal/js/bootstrap.min.js HTTP/1.1" 404 1890
[11/Feb/2018 00:45:11] "GET /static/bower_components/bootstrap/css/bootstrap.min.css HTTP/1.1" 404 1869
[11/Feb/2018 00:45:11] "GET /static/internal/css/AdminLTE.min.css HTTP/1.1" 404 1812
[11/Feb/2018 00:45:11] "GET /static/internal/css/general.css HTTP/1.1" 404 1797
[11/Feb/2018 00:45:11] "GET /static/internal/css/skins/all-skins.min.css HTTP/1.1" 404 1833
[11/Feb/2018 00:45:11] "GET /static/bower_components/jquery/internal/jquery.min.js HTTP/1.1" 404 1863
[11/Feb/2018 00:45:11] "GET /static/bower_components/bootstrap/internal/js/bootstrap.min.js HTTP/1.1" 404 1890
试试这个:

STATIC_URL = '/static/'
STATICFILES_DIRS = [
    os.path.join(BASE_DIR, "static")
]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')