嘿,伙计们,我有麻烦,在显示所有贴子与相同的关联id和相关id来自qna,我想显示所有的关联id贴到qna_邮政.html请帮助在django 1.11 python3中修复它
你知道吗网址.py你知道吗
from django.conf.urls import url, include
from django.views.generic import ListView, DetailView
from qna.models import Post
urlpatterns = [
url(r'^$', ListView.as_view(queryset=Post.objects.all().order_by("-date")[:25], template_name="qna.html")),
url(r'^(?P<pk>\d+)$', DetailView.as_view(model = Post, template_name= 'qna_post.html'))
]
qna公司_邮政.html “{%扩展”标题.html“%}
{% block content %}
{% for post in object_list %}
{% url page_item item.id %}
{% if post.relatedid == post.id %}
{% if post.PostType == 'q' %}
<h3>{{ post.Title }}</h3>
<h6>on {{ post.date }}</h6>
{{post.Body|safe|linebreaks}}
{% endif %}
{% if post.PostType == 'a' %}
<h3>{{ post.Title }}</h3>
<h6>on {{ post.date }}</h6>
{{post.Body|safe|linebreaks}}
{% endif %}
{% endif %}
{% endfor %}
{% endblock %}
你知道吗qna.html文件你知道吗
{% extends "header.html" %}
{% block content %}
{% for post in object_list %}
{% if post.PostType == 'q' %}
<h5>{{ post.date|date:"Y-m-d" }}<a href="/questions/{{ post.id }}"> {{ post.Title }}</a> -<label> {{ post.Body|slice:":8" }}...</label></h5>
{% endif %}
{% endfor %}
{% endblock %}
目前没有回答
相关问题 更多 >
编程相关推荐