HI I am new to static files but I got this error called STATICFILES_DIRS setting is not a tuple or list. Which I do not understand as it is does not contain any commas. I hope someone can help me. Yes, I have imported os.
Traceback:
ERRORS:
?: (staticfiles.E001) The STATICFILES_DIRS setting is not a tuple or list.
HINT: Perhaps you forgot a trailing comma?
Run Code Online (Sandbox Code Playgroud)
settings.py:
STATICFILES_DIRS = [
os.path.join(BASE_DIR, 'static')
]
STATICFILES_DIRS = (
os.path.join(BASE_DIR, '')
)
Run Code Online (Sandbox Code Playgroud) 我需要限制 Django 查询中的帖子数量。我试图添加一个最小值和最大值,但似乎没有任何效果。我已将 home.html 添加到代码中。
示例:我的博客中应该只有 15 篇最新的帖子。其余的可以通过单击类别按钮来查看。
主页.html:
{% extends 'base.html' %}
{% block content %}
<h1>Posts</h1>
<ul>
{% for post in object_list %}
<li><a href="{% url 'article-detail' post.pk %}">{{post.title}}</a>
<style>
a {
text-transform: capitalize;
}
</style>
- <a href="{% url 'category' post.category %}">{{ post.category }}</a> - <a href="{% url 'show_profile_page' post.author.profile.id %}">{{ post.author.first_name }}
{{ post.author.last_name }}</a> - {{ post.post_date }} <small>
{% if user.is_authenticated %}
{% if user.id == post.author.id %}
- <a href="{% url 'update_post' post.pk …Run Code Online (Sandbox Code Playgroud)