我第一次用django开发。我已经阅读了什么:/ # start pattern
\{ # match opening curly bracket
\s* # match zero or more whitespace characters
bidder:\s*'internal' # match bidder, zero or more whitespaces, single quote, internal, then single quote
[^}]* # greedily match anything that is not a closing curly bracket (zero or more)
\} # match a closing curly bracket
[^}]* # greedily match anything that is not a closing curly bracket (zero or more)
\} # match a closing curly bracket
/ # end pattern
,我知道每个人的目的是什么。
我遇到了一个问题,我一直在试图获取css文件的浏览器上获得404。
STATIC_ROOT / STATICFILES_DIR / STATIC_URL
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
PROJECT_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_URL = '/static/'
STATIC_ROOT = '%s/online_static/' % (BASE_DIR)
STATICFILES_DIRS = ['%s/bootstrap/' % (PROJECT_DIR),]
设置此参数后,我运行了<head>
{% load staticfiles %}
<meta charset="UTF-8">
<title>{% block title%}Default title{% endblock title %}</title>
<meta name="description" content="{% block metadescription%}{% endblock metadescription %}">
<meta name="keywords" content="{% block metakeywords%}{% endblock metakeywords %}">
<meta name="author" content="alme7airbi9357@gmail.com">
<!-- Bootstrap core CSS -->
<link href="{% static 'vendor/bootstrap/css/bootstrap.min.css' %}" type="text/css" rel="stylesheet">
<!-- Custom styles for this template -->
<link href="{% static 'css/shop-homepage.css' %}" rel="stylesheet" type="text/css">
<!-- Bootstrap core JavaScript -->
<script src="{% static 'vendor/jquery/jquery.min.js' %}"></script>
<script src="{% static 'vendor/bootstrap/js/bootstrap.bundle.min.js' %}"></script>
</head>
注意:python manage.py collectstatic