python - how to show all post with relatedid in django? -
hey guys have trouble in display post same relatedid , related id comes qna , want show relatedid post qna_post.html please fix in django 1.11 python3
urls.py
from django.conf.urls import url, include django.views.generic import listview, detailview 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_post.html {% extends "header.html" %}
{% block content %} {% 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 %} {% 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 %}
Comments
Post a Comment