In the groups/views.py:
groups/urls.py:
groups/group_detail.html:
posts/_post.html:
How do I use pagination in the DetailView? I only know to use it in ListView so far using the tutorials. I would gladly give more of the codes if the above are not helpful enough to solve the problem. Thank you in advance whoever can help!
-- class SingleGroup(generic.DetailView):
model = Group
groups/urls.py:
url(r'^posts/group/(?P<slug>[-\w]+)/$', views.SingleGroup.as_view(), name='single_group'),
groups/group_detail.html:
{% extends 'groups/group_base.html' %}
{% block pre-group %}
<div class="col-md-4">
<h1>{{ group.group_name }}</h1>
<h2>Members Count: {{ group.members.count }}</h2>
<div class="content">
{% if user in group.members.all %}
<a class="btn btn-warning" href="{% url 'groups:leave_group' slug=group.slug %}"><span class="glyphicon glyphicon-remove-circle"></span> Leave Group</a>
{% else %}
<a class="btn btn-warning" href="{% url 'groups:join_group'
slug=group.slug %}"><span class="glyphicon
glyphicon-ok-circle"></span> Join Group</a>
{% endif %}
</div>
</div>
{% endblock %}
{% block group_content %}
<div class="col-md-8">
{% if group.post_counts.count == 0 %}
<h2>No posts found</h2>
{% else %}
{% for post in group.posts.all %}
{% include 'posts/_post.html' %}
{% endfor %}
{% endif %}
</div>
{% endblock %}
posts/_post.html:
<div class="post media">
<h3>{{ post.message_html|safe }}</h3>
<div class="media-body">
<strong>
{{ post.user.username }}
</strong>
<h5 class="media-heading">
<span class="username"><a href="{% url 'posts:user_posts' username=post.user.username %}">@{{ post.user.username }}</a></span>
<time class="time"><a href="{% url 'posts:single_post' username=post.user.username pk=post.pk %}">{{ post.date_created }}</a></time>
{% if post.group %}
<span class="group-name">in <a href="#">{{ post.group.group_name }}</a></span>
{% endif %}
</h5>
<div class="media-footer">
{% if user.is_authenticated and post.user == user and not hide_delete_button %}
<a href="{% url 'posts:delete_post' pk=post.pk %}" class="btn btn-danger">
<span class="glyphicon glyphicon-remove text-danger" aria-hidden="true"></span>
<span class="text-danger icon-label"></span> Delete
</a>
{% endif %}
</div>
</div>
</div>
How do I use pagination in the DetailView? I only know to use it in ListView so far using the tutorials. I would gladly give more of the codes if the above are not helpful enough to solve the problem. Thank you in advance whoever can help!
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/99a2b13d-73d1-4219-b319-16bedd97b3cb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
No comments:
Post a Comment