On Monday, February 13, 2017 at 1:03:23 AM UTC+5:30, Kazi Atik wrote:
>
> here is my views/
>
> from django.contrib.auth.models import User
>
> from django.core.paginator import Paginator,EmptyPage, PageNotAnInteger
> from friends.models import Friendship,UserProfile
> from django.http import HttpResponse, HttpResponseRedirect, Http404
> from django.shortcuts import render
>
>
> def dashboard(request):
>     if request.method == "GET":
>         if request.user.is_authenticated():
>             userp=UserProfile.objects.filter(user=request.user)
>             return render(request, 'dashboard.html', context={ "user": 
> request.user, "userslist" : 
> User.objects.all(),"userprofile":userp,"friendshiplist": 
> Friendship.objects.filter(user1=request.user)})
>         elif request.user.is_anonymous():
>             return HttpResponse('Hi Guest. Please login to view your 
> dashboard <a href="/login/">Login</a>')
>     elif request.method=="POST":
>         raise Http404("dashboard does not support post")
>
> def listing(request):
>     users_list = User.objects.all()
>     page = request.GET.get('page', 1)
>
>     paginator = Paginator(users_list, 3)
>     try:
>         user_list = paginator.page(page)
>     except PageNotAnInteger:
>         # If page is not an integer, deliver first page.
>         user_list = paginator.page(1)
>     except EmptyPage:
>         # If page is out of range (e.g. 9999), deliver last page of results.
>         user_list = paginator.page(paginator.num_pages)
>
>     return render(request, 'dashboard.html', {'users': user_list})
>
>
> tempalates/
>
>
> <table class="table table-bordered">
> <thead>
> <th>People you may know
> </th>
> <th>Request</th>
> </thead>
>
>      {% for myuser in userslist %}
>      <div>
>
>
>            <tr>
>                <td>{{ myuser.username }}
>                </td>
>                <td>
>         <a href="/addfriend/?user={{ myuser.username }}">Add</a>
>       </td> </tr>
>      </div>
>      {% endfor %}
>
>  <ul class="pagination">
>    {% if users.has_previous %}
>      <li><a href="?page={{ users.previous_page_number }}">&laquo;</a></li>
>    {% else %}
>      <li class="disabled"><span>&laquo;</span></li>
>    {% endif %}
>    {% for i in users.paginator.page_range %}
>      {% if users.number == i %}
>        <li class="active"><span>{{ i }} <span 
> class="sr-only">(current)</span></span></li>
>      {% else %}
>        <li><a href="?page={{ i }}">{{ i }}</a></li>
>      {% endif %}
>    {% endfor %}
>    {% if users.has_next %}
>      <li><a href="?page={{ users.next_page_number }}">&raquo;</a></li>
>    {% else %}
>      <li class="disabled"><span>&raquo;</span></li>
>    {% endif %}
>  </ul>
>
> </table>
>
>
>
> <https://lh3.googleusercontent.com/-IBjBMf92OOQ/WKC4R3ZxNnI/AAAAAAAAHiU/WMDc1RWgKo4cpuYVNM2NQpU5RR98jUZaACLcB/s1600/Ca.PNG>
>
> i am trying to paginate this but not getting any result
>
>
> please help me 
>
>
> whatsapp-8867203481
>
>
>
>
> please help me on this code
>
>
>
>

-- 
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+unsubscr...@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/7d582ad8-20bf-44c7-a724-79dfbb565d19%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to