pagination support on async function.

2023-11-28 Thread seokhyun an
hi. 
I have worked for django using pagination on async function
but it seems to having errors cause of default Paginator. 
(like in the counting functions)

is there any plan to make it support async by Paginator itself? 
or is it already has kind of functionalities but I just have not found one? 


-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5294dc17-3950-4cef-95dd-0c87a2370955n%40googlegroups.com.


Re: Pagination on different cards reside on the same template

2021-11-25 Thread Eugene TUYIZERE
Dear David, 

Thanks, after some hours of search,I managed to achieve it with python only.



> On 25 Nov 2021, at 23:26, David Nugent  wrote:
> 
> Hi Eurgene,
> 
> I would implement this in Javascript (or htmx). Some good examples are only a 
> google search away.
> 
> Regards, David
> 
>> On Fri, Nov 26, 2021 at 6:41 AM Eugene TUYIZERE  
>> wrote:
>> Dear Team,
>> 
>> I have 4 cards on a single html page. I want to display data on each one but 
>> since the data has many rows I want to apply pagination on each card. How 
>> can I achieve this? I was thinking of using ListView but this displays 
>> pagination on the whole page. I did not try any other codes because I have 
>> no idea
>> 
>> Kindly assist.
>> -- 
>> Eugene
>> 
>> 
>> 
>> -- 
>> 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 view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CABxpZHvBC0ifjPY8URFq5HdFtJhhYnSbECT6f7Vtr8dX06otAg%40mail.gmail.com.
> 
> -- 
> 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 view this discussion on the web visit 
> https://groups.google.com/d/msgid/django-users/CAE5VhgViNLYcVwkBZMYA4hN9b0TymjTULoRsbQ06Mof5PYKxKA%40mail.gmail.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/51050674-2DD8-4DAF-97B6-1FA96D55ABEF%40gmail.com.


Re: Pagination on different cards reside on the same template

2021-11-25 Thread David Nugent
Hi Eurgene,

I would implement this in Javascript (or htmx). Some good examples are only
a google search away.

Regards, David

On Fri, Nov 26, 2021 at 6:41 AM Eugene TUYIZERE 
wrote:

> Dear Team,
>
> I have 4 cards on a single html page. I want to display data on each one
> but since the data has many rows I want to apply pagination on each card.
> How can I achieve this? I was thinking of using ListView but this displays
> pagination on the whole page. I did not try any other codes because I have
> no idea
>
> Kindly assist.
> --
> *Eugene*
>
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CABxpZHvBC0ifjPY8URFq5HdFtJhhYnSbECT6f7Vtr8dX06otAg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CABxpZHvBC0ifjPY8URFq5HdFtJhhYnSbECT6f7Vtr8dX06otAg%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAE5VhgViNLYcVwkBZMYA4hN9b0TymjTULoRsbQ06Mof5PYKxKA%40mail.gmail.com.


Pagination on different cards reside on the same template

2021-11-25 Thread Eugene TUYIZERE
Dear Team,

I have 4 cards on a single html page. I want to display data on each one
but since the data has many rows I want to apply pagination on each card.
How can I achieve this? I was thinking of using ListView but this displays
pagination on the whole page. I did not try any other codes because I have
no idea

Kindly assist.
-- 
*Eugene*

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABxpZHvBC0ifjPY8URFq5HdFtJhhYnSbECT6f7Vtr8dX06otAg%40mail.gmail.com.


Re: Django Pagination paginate dictionary of objects

2020-07-28 Thread jhabar singh
bro try to send a intended code

On Tue, Jul 28, 2020 at 5:16 PM Harvindar Singh Garcha <
garchaama...@gmail.com> wrote:

> I am new to Django, and trying to paginate a dictionary objects,
> However I am unable to so and not getting what's wrong with my code,
> Its still printing whole data on a single page. Above I have posted my
> View along with template code.
>
>
> class Search(ListView):
>  paginate_by = 5
>
>  def get(self, request):
>  if 'search' in request.GET:
>  search = request.GET['search']
>  url = '
> https://api.stackexchange.com/2.2/search/advanced?=stackoverflow'
>  params = dict(item.split("=") for item in search.split(","))
>  req = PreparedRequest()
>  req.prepare_url(url, params)
>  stackoverflow_url = req.url
>  response = requests.get(stackoverflow_url)
>  data = response.json()
>  #Data will be like this
>  # data={{'tag':'python','question':'some
> question'},{'tag':'java','question':'some question'}}
>  # n here is 2
>  paginator = Paginator(list(data), 5)
>  page_number = request.GET.get('search')
>  page_obj = paginator.get_page(page_number)
>  return render(request, 'stackoverflow.html', {
>  'data': data,
>  'page_obj': page_obj
>
>  })
>
>
>
>
>
>
>
>
> {%if data %}
> 
>  
> 
>  {% for key,value in data.items %}
>  
>  
> {{ value.title }}
> {{ value.creation_date }} 
>  Asked By  "{{value.owner_link}}">{{value.display_name }} 
>   >Read More   
>  {% endfor %}
>  
> 
> 
> 
> 
> {% if value.has_previous %}
>  first
> previous
> {% endif %}
>  Page {{ page_obj.number }} of {{
> page_obj.paginator.num_pages }}.
>  
>  {% if page_obj.has_next %}
>  next
> last 
>  {% endif %}
>  
>  
> {% else %}
>  No Results found :(
> {% endif %}
> {% endblock content %}
>
>
>
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/f2aeb012-8bad-4234-9a4f-635fe1a8698ao%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAJ1QTg%3Dq-dCPgexPQmSZ5w8seqh71K-sByLei%2BXkQHs5soj6WA%40mail.gmail.com.


Django Pagination paginate dictionary of objects

2020-07-28 Thread Harvindar Singh Garcha
I am new to Django, and trying to paginate a dictionary objects,
However I am unable to so and not getting what's wrong with my code,
Its still printing whole data on a single page. Above I have posted my View 
along with template code. 


class Search(ListView):
 paginate_by = 5

 def get(self, request):
 if 'search' in request.GET:
 search = request.GET['search']
 url = 
'https://api.stackexchange.com/2.2/search/advanced?=stackoverflow'
 params = dict(item.split("=") for item in search.split(","))
 req = PreparedRequest()
 req.prepare_url(url, params)
 stackoverflow_url = req.url
 response = requests.get(stackoverflow_url)
 data = response.json()
 #Data will be like this
 # data={{'tag':'python','question':'some 
question'},{'tag':'java','question':'some question'}}
 # n here is 2
 paginator = Paginator(list(data), 5)
 page_number = request.GET.get('search')
 page_obj = paginator.get_page(page_number)
 return render(request, 'stackoverflow.html', {
 'data': data,
 'page_obj': page_obj

 })








{%if data %} 
 
  

 {% for key,value in data.items %}
 
  
{{ value.title }} 
{{ value.creation_date }}  
 Asked By {{value.display_name }}  
 
Read More   
 {% endfor %}
  
 
 
 
 
{% if value.has_previous %} 
 first
previous 
{% endif %} 
 Page {{ page_obj.number }} of {{ 
page_obj.paginator.num_pages }}.
 
 {% if page_obj.has_next %}
 next 
last 
 {% endif %}
 
  
{% else %}
 No Results found :( 
{% endif %} 
{% endblock content %}





-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/f2aeb012-8bad-4234-9a4f-635fe1a8698ao%40googlegroups.com.


Django Pagination paginate dictionary of objects

2020-07-28 Thread Harvindar Singh Garcha
I am new to Django, and trying to paginate a dictionary objects, I am 
calling stackoverflow API where I want the result to get paginated. However 
I am unable to so and not getting what's wrong with my code. Above I have 
posted my View along with template code.

>
>
> class Search(ListView):
>  paginate_by = 5
>
>  def get(self, request):
>  if 'search' in request.GET:
>  search = request.GET['search']
>  url = 
> 'https://api.stackexchange.com/2.2/search/advanced?=stackoverflow'
>  params = dict(item.split("=") for item in search.split(","))
>  req = PreparedRequest()
>  req.prepare_url(url, params)
>  stackoverflow_url = req.url
>  response = requests.get(stackoverflow_url)
>  data = response.json()
>  #Data will be like this
>  # data={{'tag':'python','question':'some 
> question'},{'tag':'java','question':'some question'}}
>  # n here is 2
>  paginator = Paginator(list(data), 5)
>  page_number = request.GET.get('search')
>  page_obj = paginator.get_page(page_number)
>  return render(request, 'stackoverflow.html', {
>  'data': data,
>  'page_obj': page_obj
>
>  })
>
>>
>>

My template file


{%if data %}
 
 
 
 
 {% for key,value in data.items %}
 
 
 {{ value.title }}
 {{ value.creation_date }} 
  Asked By
 {{value.display_name }} 
 
 Read More 
 
 
 
 {% endfor %}
 
 
 
 
 
 
 
 {% if value.has_previous %}
  first
 previous
 {% endif %}
 
 Page {{ page_obj.number }} of {{ page_obj.paginator.num_pages }}.
 
 {% if page_obj.has_next %}
 next
 last 
 {% endif %}
 
 
{% else %}
 No Results found :(
{% endif %}
 
{% endblock content %}







*Can someone tell me what's wrong with my code, I am unable to get a 
paginated result, everything is coming all together on single page.*




-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/683ad3c2-16d6-4eea-9074-5336251165aeo%40googlegroups.com.


Re: randomizing objects in the view with pagination

2020-07-12 Thread Damanjeet Singh
Hello,

I have been using random module (django-random-queryset)  for site
https://www.euroautozone.com. Performance is not bad.

here is the code

models.py

class product(models.Model):
##Slug
objects = RandomManager()

Views.py

   query = product.objects.filter(Q(title__icontains=query)

  |
  Q(description__icontains=query)
  |
  Q(customLabel__icontains=query)
  |
  Q(advertiserName__icontains=query)
  |
  Q(brand__icontains=query)

).filter(siteName__icontains=getCurrentSite(request)).distinct()

 all_information=query.random(1000)


Regards,

Damanjeet


On Sun, Jul 12, 2020 at 7:57 PM MUGOYA DIHFAHSIH 
wrote:

> Am anxiously waiting for the answer to this question cos i would like to
> do the same for my django web app
>
> On Sun, Jul 12, 2020, 19:46 John McClain  wrote:
>
>> I have a marketplace with many sellers selling the same 3 products in
>> various values. In all the are 18 product type for sell on the platform
>> with hundreds of sellers.
>>
>> I was randomizing the product category page when loaded so that items
>> from all sellers could appear on the page.
>>
>> I was not using paginations and I have thousands of products so the page
>> was obviously loading very slow.
>>
>> I added pagination and let python manage the query instead of it
>> happening on the server-side. This increased the page load but I lost my
>> randomization.
>>
>> The first page is the only page getting random items loaded. When using
>> pagination to get to the 2nd page the items loading on that page are
>> descending oldest to newest.
>>
>> Does anyone have an idea how to manage randomizing items on each new page?
>>
>> I am django core paginator
>>
>> https://docs.djangoproject.com/en/3.0/ref/paginator/
>>
>> Any ideas would be appreciated
>>
>> Cheers,
>>
>> John
>>
>> --
>> John McClain
>>
>> Cell: 085-1977-823
>> Skype: jmcclain0129
>> Email: jmcclain0...@gmail.com
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/CAN-hv_qyzZQdCXJBRs_a-3MEt46%3DsOtXvknNuEVBzWNZ_bk5Xg%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAN-hv_qyzZQdCXJBRs_a-3MEt46%3DsOtXvknNuEVBzWNZ_bk5Xg%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAP%3DJD9z6-8PXmm5Pmh8LjTCi7m%2BajFG1wwWPQZGFZ56W5%2BooQw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAP%3DJD9z6-8PXmm5Pmh8LjTCi7m%2BajFG1wwWPQZGFZ56W5%2BooQw%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGLHGi6sn6T1AFE6RF%2BPCuiv9Sy%3DkEi_Q-PDLUWQom%3DhByjhOw%40mail.gmail.com.


Re: randomizing objects in the view with pagination

2020-07-12 Thread MUGOYA DIHFAHSIH
Am anxiously waiting for the answer to this question cos i would like to do
the same for my django web app

On Sun, Jul 12, 2020, 19:46 John McClain  wrote:

> I have a marketplace with many sellers selling the same 3 products in
> various values. In all the are 18 product type for sell on the platform
> with hundreds of sellers.
>
> I was randomizing the product category page when loaded so that items from
> all sellers could appear on the page.
>
> I was not using paginations and I have thousands of products so the page
> was obviously loading very slow.
>
> I added pagination and let python manage the query instead of it happening
> on the server-side. This increased the page load but I lost my
> randomization.
>
> The first page is the only page getting random items loaded. When using
> pagination to get to the 2nd page the items loading on that page are
> descending oldest to newest.
>
> Does anyone have an idea how to manage randomizing items on each new page?
>
> I am django core paginator
>
> https://docs.djangoproject.com/en/3.0/ref/paginator/
>
> Any ideas would be appreciated
>
> Cheers,
>
> John
>
> --
> John McClain
>
> Cell: 085-1977-823
> Skype: jmcclain0129
> Email: jmcclain0...@gmail.com
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAN-hv_qyzZQdCXJBRs_a-3MEt46%3DsOtXvknNuEVBzWNZ_bk5Xg%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAN-hv_qyzZQdCXJBRs_a-3MEt46%3DsOtXvknNuEVBzWNZ_bk5Xg%40mail.gmail.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAP%3DJD9z6-8PXmm5Pmh8LjTCi7m%2BajFG1wwWPQZGFZ56W5%2BooQw%40mail.gmail.com.


randomizing objects in the view with pagination

2020-07-12 Thread John McClain
I have a marketplace with many sellers selling the same 3 products in
various values. In all the are 18 product type for sell on the platform
with hundreds of sellers.

I was randomizing the product category page when loaded so that items from
all sellers could appear on the page.

I was not using paginations and I have thousands of products so the page
was obviously loading very slow.

I added pagination and let python manage the query instead of it happening
on the server-side. This increased the page load but I lost my
randomization.

The first page is the only page getting random items loaded. When using
pagination to get to the 2nd page the items loading on that page are
descending oldest to newest.

Does anyone have an idea how to manage randomizing items on each new page?

I am django core paginator

https://docs.djangoproject.com/en/3.0/ref/paginator/

Any ideas would be appreciated

Cheers,

John

-- 
John McClain

Cell: 085-1977-823
Skype: jmcclain0129
Email: jmcclain0...@gmail.com

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAN-hv_qyzZQdCXJBRs_a-3MEt46%3DsOtXvknNuEVBzWNZ_bk5Xg%40mail.gmail.com.


Re: pagination of a specific context in multiple context in ListView not working in django?

2020-06-08 Thread Sunday Iyanu Ajayi
 Modify this:

activities = paginator.page(page)
 data = activities .object_list
return (data)
*AJAYI Sunday *
(+234) 806 771 5394
*sunnexaj...@gmail.com *



On Tue, Jun 2, 2020 at 12:52 AM Ali Ahammad  wrote:

> in django, i am trying to list some queries of several objects like user
> lists, categoies and Post list. the homepage will be contained couple of
> blocks or boxes. each box will have different query list like Post list,
> User List, category list. But only one context will have pagination and
> other won't and ofcourse the pagination will be working on Post list.
>
> here is the views.py:
>
> class BlogappListView(ListView):
> model = Category,CustomUser
> template_name = 'home.html'
> context_object_name='category_list'
> queryset=Category.objects.all()
> paginate_by = 2
>
> def get_context_data(self, **kwargs):
> context = super(BlogappListView, self).get_context_data(**kwargs)
> context['user_list']= CustomUser.objects.all()
> context['post_list']=Post.objects.all()
> activities=context['post_list']
> return context
> def get_related_activities(self,activities):
> queryset=self.objects.activity_rel.all()
> paginator=Paginator(queryset,2)
> page=self.request.GET.get('page')
> activities=paginator.get_page(page)
> return(activities)
> in urls.py:
>
> urlpatterns = [
> path('',BlogappListView.as_view(),name='home'),
> ]
> in base.html, the paginate portion code:
>
> 
>   {% if is_paginated %}
>
> {% if page_obj.has_previous %}
> 
> First
>   
>   
>   Previous
> 
> {% endif %}
>
> {% for num in page_obj.paginator.page_range %}
>   {% if page_obj.number == num %}
>   
> {{ num
> }}
>   
>
>   {% elif num > page_obj.number|add:'-3' and num <
> page_obj.number|add:'3' %}
>   
> {{ num
> }}
>   
>
>   {% endif %}
> {% endfor %}
>
> {% if page_obj.has_next %}
> 
>   Next
> 
>   
>   Last
> 
>
> {% endif %}
>
>   {% endif %}
> 
> the main problem is that page number 1 is showing all the posts and also
> the second page. and category list is also truncated into 2 but the user
> list ok.
>
> so how can i make it work ? is there any other way?
>
> thank you in advance
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/695c35d0-4841-4aaf-9080-7817cbe27fa9%40googlegroups.com
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAKYSAw2DphFkhdz4FjzZf8-jXBhDwBmKZiYZLJP8tjSXmnX4sw%40mail.gmail.com.


Re: pagination of a specific context in multiple context in ListView not working in django?

2020-06-02 Thread Hella Nick
Do you use Django or Django Rest Framework?

Ali Ahammad  于2020年6月2日周二 上午7:51写道:

> in django, i am trying to list some queries of several objects like user
> lists, categoies and Post list. the homepage will be contained couple of
> blocks or boxes. each box will have different query list like Post list,
> User List, category list. But only one context will have pagination and
> other won't and ofcourse the pagination will be working on Post list.
>
> here is the views.py:
>
> class BlogappListView(ListView):
> model = Category,CustomUser
> template_name = 'home.html'
> context_object_name='category_list'
> queryset=Category.objects.all()
> paginate_by = 2
>
> def get_context_data(self, **kwargs):
> context = super(BlogappListView, self).get_context_data(**kwargs)
> context['user_list']= CustomUser.objects.all()
> context['post_list']=Post.objects.all()
> activities=context['post_list']
> return context
> def get_related_activities(self,activities):
> queryset=self.objects.activity_rel.all()
> paginator=Paginator(queryset,2)
> page=self.request.GET.get('page')
> activities=paginator.get_page(page)
> return(activities)
> in urls.py:
>
> urlpatterns = [
> path('',BlogappListView.as_view(),name='home'),
> ]
> in base.html, the paginate portion code:
>
> 
>   {% if is_paginated %}
>
> {% if page_obj.has_previous %}
> 
> First
>   
>   
>   Previous
> 
> {% endif %}
>
> {% for num in page_obj.paginator.page_range %}
>   {% if page_obj.number == num %}
>   
> {{ num
> }}
>   
>
>   {% elif num > page_obj.number|add:'-3' and num <
> page_obj.number|add:'3' %}
>   
> {{ num
> }}
>   
>
>   {% endif %}
> {% endfor %}
>
> {% if page_obj.has_next %}
> 
>   Next
> 
>   
>   Last
> 
>
> {% endif %}
>
>   {% endif %}
> 
> the main problem is that page number 1 is showing all the posts and also
> the second page. and category list is also truncated into 2 but the user
> list ok.
>
> so how can i make it work ? is there any other way?
>
> thank you in advance
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/695c35d0-4841-4aaf-9080-7817cbe27fa9%40googlegroups.com
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHfGPEeNBN4pibXa064xGR6J2J7cKZshHiHUBdv88XcOUBfHGw%40mail.gmail.com.


pagination of a specific context in multiple context in ListView not working in django?

2020-06-01 Thread Ali Ahammad
in django, i am trying to list some queries of several objects like user lists, 
categoies and Post list. the homepage will be contained couple of blocks or 
boxes. each box will have different query list like Post list, User List, 
category list. But only one context will have pagination and other won't and 
ofcourse the pagination will be working on Post list.

here is the views.py:

class BlogappListView(ListView):
model = Category,CustomUser
template_name = 'home.html'
context_object_name='category_list'
queryset=Category.objects.all()
paginate_by = 2

def get_context_data(self, **kwargs):
context = super(BlogappListView, self).get_context_data(**kwargs)
context['user_list']= CustomUser.objects.all()
context['post_list']=Post.objects.all()
activities=context['post_list']
return context
def get_related_activities(self,activities):
queryset=self.objects.activity_rel.all()
paginator=Paginator(queryset,2)
page=self.request.GET.get('page')
activities=paginator.get_page(page)
return(activities)
in urls.py:

urlpatterns = [
path('',BlogappListView.as_view(),name='home'),
]
in base.html, the paginate portion code:

  
  {% if is_paginated %}

{% if page_obj.has_previous %}
  
First
  
  
  Previous

{% endif %}

{% for num in page_obj.paginator.page_range %}
  {% if page_obj.number == num %}
  
{{ num 
}}
  

  {% elif num > page_obj.number|add:'-3' and num < 
page_obj.number|add:'3' %}
  
{{ num 
}}


  {% endif %}
{% endfor %}

{% if page_obj.has_next %}

  Next

  
  Last


{% endif %}

  {% endif %}

the main problem is that page number 1 is showing all the posts and also the 
second page. and category list is also truncated into 2 but the user list ok.

so how can i make it work ? is there any other way?

thank you in advance

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/695c35d0-4841-4aaf-9080-7817cbe27fa9%40googlegroups.com.


Re: Django Pagination

2020-06-01 Thread maninder singh Kumar
I think there might be a way around, below is the code modified for views.py

@login_required
def home_view(request):
"""Display all the post of friends and own posts on the dashboard"""
posts = Post.objects.order_by('-date_posted')
media: MEDIA_URL
# 'post':Post.objects.filter(Q(author=request.user) |
Q(author__from_user=request.user) |
Q(author__to_user=request.user)).order_by('-date_posted'),
paginator = Paginator(posts, 2)
page_number = request.GET.get('page')
try:
page_obj = paginator.page('page')
except PageNotAnInteger:
page_obj = paginator.page(1)
except EmptyPage:
page_obj = paginator.page(paginator.num_pages)
return render(request, 'post/home.html',{'page_obj': page_obj})

I think this might work !

regards
willy


On Mon, Jun 1, 2020 at 7:48 PM Akshat Zala  wrote:

> Dear Sir,
>
> it shows all the text on all the pages.
>
> if there are total 5 posts, then it  shows all the 5 posts on all the
> pages.
>
> Thanks,
>
> Akshat Zala
>
> On Saturday, 30 May 2020 20:54:35 UTC+5:30, maninder singh Kumar wrote:
>>
>> Views.py looks fine !
>>
>> regards
>> willy
>>
>>
>> On Sat, May 30, 2020 at 7:22 PM Akshat Zala  wrote:
>>
>>> Hello,
>>>
>>> I am finding it difficult to paginate through all the posts
>>>
>>> My views.py :
>>>
>>> @login_required
>>> def home_view(request):
>>> """Display all the post of friends and own posts on the dashboard"""
>>> posts = Post.objects.all().order_by('-date_posted')
>>> media: MEDIA_URL
>>> # 'post':Post.objects.filter(Q(author=request.user) |
>>> Q(author__from_user=request.user) |
>>> Q(author__to_user=request.user)).order_by('-date_posted'),
>>> paginator = Paginator(posts, 2)
>>> page_number = request.GET.get('page')
>>> page_obj = paginator.get_page(page_number)
>>> return render(request, 'post/home.html',{'page_obj': page_obj})
>>>
>>>
>>> and in template post/home.html:
>>>
>>> {% if is_paginated %}
>>> {% if page_obj.has_previous %}
>>> First
>>> arrow_left
>>> 
>>> {% endif %}
>>> {% for num in page_obj.paginator.page_range %}
>>> {% if page_obj.number == num %}
>>> {{ num }}
>>> {% elif num > page_obj.number|add:'-4' and num < page_obj.number|add:'4'
>>> %}
>>> {{ num }}
>>> 
>>> {% endif %}
>>> {% endfor %}
>>> {% if page_obj.has_next %}
>>> arrow_right
>>> Last
>>> {% endif %}
>>>
>>>
>>> Thanks
>>>
>>> Akshat Zala
>>>
>>> --
>>> 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...@googlegroups.com.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/87c3f0db-3088-448c-b3c7-14450e8c2f5d%40googlegroups.com
>>> 
>>> .
>>>
>> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/c775d687-0773-4d09-86be-35e6f2cd55d2%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABOHK3T5A8JT%2BOe-Tt%3DAw4ZOff%2BwVWXO4EXMbkKtTUz2Y2spZg%40mail.gmail.com.


Re: Django Pagination

2020-06-01 Thread Akshat Zala
Dear Sir,

it shows all the text on all the pages.

if there are total 5 posts, then it  shows all the 5 posts on all the pages.

Thanks,

Akshat Zala

On Saturday, 30 May 2020 20:54:35 UTC+5:30, maninder singh Kumar wrote:
>
> Views.py looks fine !
>
> regards
> willy
>
>
> On Sat, May 30, 2020 at 7:22 PM Akshat Zala  > wrote:
>
>> Hello,
>>
>> I am finding it difficult to paginate through all the posts
>>
>> My views.py :
>>
>> @login_required
>> def home_view(request):
>> """Display all the post of friends and own posts on the dashboard"""
>> posts = Post.objects.all().order_by('-date_posted')
>> media: MEDIA_URL
>> # 'post':Post.objects.filter(Q(author=request.user) | 
>> Q(author__from_user=request.user) | 
>> Q(author__to_user=request.user)).order_by('-date_posted'),
>> paginator = Paginator(posts, 2) 
>> page_number = request.GET.get('page')
>> page_obj = paginator.get_page(page_number)
>> return render(request, 'post/home.html',{'page_obj': page_obj})
>>
>>
>> and in template post/home.html:
>>
>> {% if is_paginated %}
>> {% if page_obj.has_previous %}
>> First
>> arrow_left
>> 
>> {% endif %}
>> {% for num in page_obj.paginator.page_range %}
>> {% if page_obj.number == num %}
>> {{ num }}
>> {% elif num > page_obj.number|add:'-4' and num < page_obj.number|add:'4' 
>> %}
>> {{ num }}
>> {% endif %}
>> {% endfor %}
>> {% if page_obj.has_next %}
>> arrow_right
>> Last
>> {% endif %}
>>
>>
>> Thanks
>>
>> Akshat Zala
>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/87c3f0db-3088-448c-b3c7-14450e8c2f5d%40googlegroups.com
>>  
>> 
>> .
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c775d687-0773-4d09-86be-35e6f2cd55d2%40googlegroups.com.


Re: Django Pagination

2020-05-31 Thread Akshat Zala
Hi,

if I change the template to:

{% if not is_paginated %}
{% if page_obj.has_previous %}
First
arrow_left
{% endif %}
{% for num in page_obj.paginator.page_range %}
{% if page_obj.number == num %}
{{ num }}
{% elif num > page_obj.number|add:'-4' and num < page_obj.number|add:'4' %}
{{ num }}
{% endif %}
{% endfor %}
{% if page_obj.has_next %}
arrow_right
Last
{% endif %}
{% endif %}

It only shows pagination and posts are not seen in template.

On Saturday, 30 May 2020 21:39:52 UTC+5:30, RyuCoder wrote:
>
> Hi akshat,
> What is the difficulty?
> Where have you defined the variable   is_paginated? Is it present in the 
> context?
>
> On Sat, May 30, 2020, 8:53 PM maninder singh Kumar  > wrote:
>
>> Views.py looks fine !
>>
>> regards
>> willy
>>
>>
>> On Sat, May 30, 2020 at 7:22 PM Akshat Zala > > wrote:
>>
>>> Hello,
>>>
>>> I am finding it difficult to paginate through all the posts
>>>
>>> My views.py :
>>>
>>> @login_required
>>> def home_view(request):
>>> """Display all the post of friends and own posts on the dashboard"""
>>> posts = Post.objects.all().order_by('-date_posted')
>>> media: MEDIA_URL
>>> # 'post':Post.objects.filter(Q(author=request.user) | 
>>> Q(author__from_user=request.user) | 
>>> Q(author__to_user=request.user)).order_by('-date_posted'),
>>> paginator = Paginator(posts, 2) 
>>> page_number = request.GET.get('page')
>>> page_obj = paginator.get_page(page_number)
>>> return render(request, 'post/home.html',{'page_obj': page_obj})
>>>
>>>
>>> and in template post/home.html:
>>>
>>> {% if is_paginated %}
>>> {% if page_obj.has_previous %}
>>> First
>>> arrow_left
>>> 
>>> {% endif %}
>>> {% for num in page_obj.paginator.page_range %}
>>> {% if page_obj.number == num %}
>>> {{ num }}
>>> {% elif num > page_obj.number|add:'-4' and num < page_obj.number|add:'4' 
>>> %}
>>> {{ num }}
>>> 
>>> {% endif %}
>>> {% endfor %}
>>> {% if page_obj.has_next %}
>>> arrow_right
>>> Last
>>> {% endif %}
>>>
>>>
>>> Thanks
>>>
>>> Akshat Zala
>>>
>>> -- 
>>> 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...@googlegroups.com .
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-users/87c3f0db-3088-448c-b3c7-14450e8c2f5d%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-users/87c3f0db-3088-448c-b3c7-14450e8c2f5d%40googlegroups.com?utm_medium=email_source=footer>
>>> .
>>>
>> -- 
>> 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...@googlegroups.com .
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/CABOHK3QumzEA417%3DMV3dTwRszxmULfHp9y-tADSD56N_sTNQ5g%40mail.gmail.com
>>  
>> <https://groups.google.com/d/msgid/django-users/CABOHK3QumzEA417%3DMV3dTwRszxmULfHp9y-tADSD56N_sTNQ5g%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b91770e1-32cb-4890-bec6-257317696da6%40googlegroups.com.


Re: Django Pagination

2020-05-30 Thread Chetan Ganji
Hi akshat,
What is the difficulty?
Where have you defined the variable   is_paginated? Is it present in the
context?

On Sat, May 30, 2020, 8:53 PM maninder singh Kumar <
maninder.s.ku...@gmail.com> wrote:

> Views.py looks fine !
>
> regards
> willy
>
>
> On Sat, May 30, 2020 at 7:22 PM Akshat Zala  wrote:
>
>> Hello,
>>
>> I am finding it difficult to paginate through all the posts
>>
>> My views.py :
>>
>> @login_required
>> def home_view(request):
>> """Display all the post of friends and own posts on the dashboard"""
>> posts = Post.objects.all().order_by('-date_posted')
>> media: MEDIA_URL
>> # 'post':Post.objects.filter(Q(author=request.user) |
>> Q(author__from_user=request.user) |
>> Q(author__to_user=request.user)).order_by('-date_posted'),
>> paginator = Paginator(posts, 2)
>> page_number = request.GET.get('page')
>> page_obj = paginator.get_page(page_number)
>> return render(request, 'post/home.html',{'page_obj': page_obj})
>>
>>
>> and in template post/home.html:
>>
>> {% if is_paginated %}
>> {% if page_obj.has_previous %}
>> First
>> arrow_left
>> 
>> {% endif %}
>> {% for num in page_obj.paginator.page_range %}
>> {% if page_obj.number == num %}
>> {{ num }}
>> {% elif num > page_obj.number|add:'-4' and num < page_obj.number|add:'4'
>> %}
>> {{ num }}
>> {% endif %}
>> {% endfor %}
>> {% if page_obj.has_next %}
>> arrow_right
>> Last
>> {% endif %}
>>
>>
>> Thanks
>>
>> Akshat Zala
>>
>> --
>> 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 view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/87c3f0db-3088-448c-b3c7-14450e8c2f5d%40googlegroups.com
>> 
>> .
>>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CABOHK3QumzEA417%3DMV3dTwRszxmULfHp9y-tADSD56N_sTNQ5g%40mail.gmail.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMKMUjveFbK%2BJ3ocK-cTzo%3Dbzt8b%2BSz-dF9C64X4Law-WjkhVA%40mail.gmail.com.


Re: Django Pagination

2020-05-30 Thread maninder singh Kumar
Views.py looks fine !

regards
willy


On Sat, May 30, 2020 at 7:22 PM Akshat Zala  wrote:

> Hello,
>
> I am finding it difficult to paginate through all the posts
>
> My views.py :
>
> @login_required
> def home_view(request):
> """Display all the post of friends and own posts on the dashboard"""
> posts = Post.objects.all().order_by('-date_posted')
> media: MEDIA_URL
> # 'post':Post.objects.filter(Q(author=request.user) |
> Q(author__from_user=request.user) |
> Q(author__to_user=request.user)).order_by('-date_posted'),
> paginator = Paginator(posts, 2)
> page_number = request.GET.get('page')
> page_obj = paginator.get_page(page_number)
> return render(request, 'post/home.html',{'page_obj': page_obj})
>
>
> and in template post/home.html:
>
> {% if is_paginated %}
> {% if page_obj.has_previous %}
> First
> arrow_left
> 
> {% endif %}
> {% for num in page_obj.paginator.page_range %}
> {% if page_obj.number == num %}
> {{ num }}
> {% elif num > page_obj.number|add:'-4' and num < page_obj.number|add:'4'
> %}
> {{ num }}
> {% endif %}
> {% endfor %}
> {% if page_obj.has_next %}
> arrow_right
> Last
> {% endif %}
>
>
> Thanks
>
> Akshat Zala
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/87c3f0db-3088-448c-b3c7-14450e8c2f5d%40googlegroups.com
> 
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABOHK3QumzEA417%3DMV3dTwRszxmULfHp9y-tADSD56N_sTNQ5g%40mail.gmail.com.


Re: Django Pagination

2020-05-30 Thread Akshat Zala



On Saturday, 30 May 2020 19:20:47 UTC+5:30, Akshat Zala wrote:
>
> Hello,
>
> I am finding it difficult to paginate through all the posts
>
> My views.py :
>
> @login_required
> def home_view(request):
> """Display all the post of friends and own posts on the dashboard"""
> posts = Post.objects.all().order_by('-date_posted')
> media: MEDIA_URL
> # 'post':Post.objects.filter(Q(author=request.user) | 
> Q(author__from_user=request.user) | 
> Q(author__to_user=request.user)).order_by('-date_posted'),
> paginator = Paginator(posts, 2) 
> page_number = request.GET.get('page')
> page_obj = paginator.get_page(page_number)
> return render(request, 'post/home.html',{'page_obj': page_obj})
>
>
> and in template post/home.html:
>
> {% if is_paginated %}
> {% if page_obj.has_previous %}
> First
> arrow_left
> 
> {% endif %}
> {% for num in page_obj.paginator.page_range %}
> {% if page_obj.number == num %}
> {{ num }}
> {% elif num > page_obj.number|add:'-4' and num < page_obj.number|add:'4' 
> %}
> {{ num }}
> {% endif %}
> {% endfor %}
> {% if page_obj.has_next %}
> arrow_right
> Last
> {% endif %}
> {% endif %}
>
> Thanks
>
> Akshat Zala
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/97ffaebc-500d-4ae7-a483-bf3f785dee28%40googlegroups.com.


Django Pagination

2020-05-30 Thread Akshat Zala
Hello,

I am finding it difficult to paginate through all the posts

My views.py :

@login_required
def home_view(request):
"""Display all the post of friends and own posts on the dashboard"""
posts = Post.objects.all().order_by('-date_posted')
media: MEDIA_URL
# 'post':Post.objects.filter(Q(author=request.user) | 
Q(author__from_user=request.user) | 
Q(author__to_user=request.user)).order_by('-date_posted'),
paginator = Paginator(posts, 2) 
page_number = request.GET.get('page')
page_obj = paginator.get_page(page_number)
return render(request, 'post/home.html',{'page_obj': page_obj})


and in template post/home.html:

{% if is_paginated %}
{% if page_obj.has_previous %}
First
arrow_left
{% endif %}
{% for num in page_obj.paginator.page_range %}
{% if page_obj.number == num %}
{{ num }}
{% elif num > page_obj.number|add:'-4' and num < page_obj.number|add:'4' %}
{{ num }}
{% endif %}
{% endfor %}
{% if page_obj.has_next %}
arrow_right
Last
{% endif %}


Thanks

Akshat Zala

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/87c3f0db-3088-448c-b3c7-14450e8c2f5d%40googlegroups.com.


Implement querystring using Search option + Pagination

2020-04-27 Thread Gurmeet Kaur
Hi All,

I have a situation where currently, I am showing data using views.py
function on the template and the template shows data on the page.

The html page also has search dropdowns and those dropdowns are getting
data from the landing view function itself.

Note - This landing function is the one that is providing data to the
page + options in dropdown menus.

Also, the pagination has been implemented in the page which also changes
when the dropdown option is chosen.

Is there a way that instead of managing this from template side, can I
manage the pagination(when dropdown is chosen and when not) + dropdown
option from views side?

Thanks,
Gurmeet Kaur

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEbKJVga%3DX%3DJcQJi44PSG-szyn6AWaTeggFTixatMVNY7WJc9g%40mail.gmail.com.


Pagination in Admin class

2020-01-11 Thread Bruckner de Villiers
Does anyone have some example code to achieve pagination to display a model 
with many records in Admin, please?

 

admin.py – 

 

class CurrencyAdmin(admin.ModelAdmin):

    paginate_by=10

    list_display = ('id', 'currency_Code', 'currency_Description')

    fieldsets = (

    (None, {'fields':('currency_Code', 'currency_Description')}),

    )

 

Much obliged,

 

Bruckner de Villiers

083 625 1086

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/09547993-6AD3-4118-8F06-9A85193E3A4C%40gmail.com.


Re: where is the error in pagination?

2019-09-25 Thread leb dev

>
> 
>>
>> 
>>
>> {% if object_list.has_previous %}
>>
>>  first
>>
>> previous
>>
>> {% endif %}
>>
>>
>>> 
>>
>> Page {{ object_list.number }} of {{ 
>>> object_list.paginator.num_pages }}.
>>
>> 
>>
>>
>>> {% if object_list.has_next %}
>>
>> next
>>
>> last 
>>
>> {% endif %}
>>
>> 
>>
>> 
>>
>>
On Wednesday, September 25, 2019 at 2:39:16 PM UTC+3, laya Mahmoudi wrote:
>
> Would you send your html codes relating to pagination
>
> در تاریخ چهارشنبه ۲۵ سپتامبر ۲۰۱۹،‏ ۱۵:۰۳ leb dev  
> نوشت:
>
>> i tried your answer and display an error :
>>
>> That page number is not an integer
>>
>> -- 
>> 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...@googlegroups.com.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/0323b126-726e-4889-beee-b68988b1a3f1%40googlegroups.com
>>  
>> <https://groups.google.com/d/msgid/django-users/0323b126-726e-4889-beee-b68988b1a3f1%40googlegroups.com?utm_medium=email_source=footer>
>> .
>
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0ad0f775-92f0-4621-b491-5d97a7f9270a%40googlegroups.com.


Re: where is the error in pagination?

2019-09-25 Thread laya Mahmoudi
Would you send your html codes relating to pagination

در تاریخ چهارشنبه ۲۵ سپتامبر ۲۰۱۹،‏ ۱۵:۰۳ leb dev 
نوشت:

> i tried your answer and display an error :
>
> That page number is not an integer
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/0323b126-726e-4889-beee-b68988b1a3f1%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/0323b126-726e-4889-beee-b68988b1a3f1%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CABL_bk0%2BFNJzKA%2BbsESdz5g%3D6HODB8LiwxXiJFQ%2BOPnHtw6v1Q%40mail.gmail.com.


Re: where is the error in pagination?

2019-09-25 Thread leb dev
i tried your answer and display an error :

That page number is not an integer

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0323b126-726e-4889-beee-b68988b1a3f1%40googlegroups.com.


RE: where is the error in pagination?

2019-09-25 Thread laya
Try this one :
paginator = Paginator(queryset_list,8)  # Show 25 contacts per page
page_request_var = "page"
page = request.GET.get(page_request_var)
try:
queryset = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
queryset = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. ), deliver last page of results.
queryset = paginator.page(paginator.num_pages)


Sent from Mail for Windows 10

From: leb dev
Sent: Wednesday, September 25, 2019 2:32 PM
To: Django users
Subject: where is the error in pagination?

i have a django project  and it includes pagination i do not know where is the 
error in my code but once i tired to go to the next or previous page it crash 
and display the below error :

> can only concatenate str(not ""NoneType) to str

            query=request.GET.get("search")
            paginator = Paginator(queryset_list, 5) 
            page_request_var = "page"
            print("page_request_var===>",page_request_var)
            page = request.GET.get(page_request_var)
            print("page===>",page)
            queryset = paginator.get_page(page)
            print("queryset===>",queryset)

When i print **page** it display None


 In the browser it suppose to display **page=2=sam**
but instead 
it display **/?=2&20search%20=%20sam**
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/82e3fe0e-e872-4a49-b869-2b67001e3270%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5d8b4c32.1c69fb81.58d02.1858%40mx.google.com.


Re: where is the error in pagination?

2019-09-25 Thread leb dev
no i am using function based views

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/bf45aef0-f237-43b4-b7fd-49bea6673b36%40googlegroups.com.


RE: where is the error in pagination?

2019-09-25 Thread laya
Hi,
Do you use Class Based View ?


Sent from Mail for Windows 10

From: leb dev
Sent: Wednesday, September 25, 2019 2:32 PM
To: Django users
Subject: where is the error in pagination?

i have a django project  and it includes pagination i do not know where is the 
error in my code but once i tired to go to the next or previous page it crash 
and display the below error :

> can only concatenate str(not ""NoneType) to str

            query=request.GET.get("search")
            paginator = Paginator(queryset_list, 5) 
            page_request_var = "page"
            print("page_request_var===>",page_request_var)
            page = request.GET.get(page_request_var)
            print("page===>",page)
            queryset = paginator.get_page(page)
            print("queryset===>",queryset)

When i print **page** it display None


 In the browser it suppose to display **page=2=sam**
but instead 
it display **/?=2&20search%20=%20sam**
-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/82e3fe0e-e872-4a49-b869-2b67001e3270%40googlegroups.com.

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/5d8b498a.1c69fb81.2757b.7648%40mx.google.com.


where is the error in pagination?

2019-09-25 Thread leb dev
i have a django project  and it includes pagination i do not know where is 
the error in my code but once i tired to go to the next or previous page it 
crash and display the below error :

> can only concatenate str(not ""NoneType) to str

query=request.GET.get("search")
paginator = Paginator(queryset_list, 5) 
page_request_var = "page"
print("page_request_var===>",page_request_var)
page = request.GET.get(page_request_var)
print("page===>",page)
queryset = paginator.get_page(page)
print("queryset===>",queryset)

When i print **page** it display None


 In the browser it suppose to display **page=2=sam**
but instead 
it display **/?=2&20search%20=%20sam**

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/82e3fe0e-e872-4a49-b869-2b67001e3270%40googlegroups.com.


Re: how to use django pagination with sql query and not ORM

2019-09-24 Thread Deep Sukhwani
Have you tried using the *.query* on Django's QuerySet (documentation: [1])

For example, if my QuerySet is:
*User.objects.filter(username__contains='alpha')*

I can obtain the underlying raw SQL Query using:
*print(User.objects.filter(username__contains='alpha').query)*
*>>> *print(User.objects.filter(username__contains='alpha').query)
SELECT `auth_user`.`id`, `auth_user`.`password`, `auth_user`.`last_login`,
`auth_user`.`is_superuser`, `auth_user`.`username`,
`auth_user`.`first_name`, `auth_user`.`last_name`, `auth_user`.`email`,
`auth_user`.`is_staff`, `auth_user`.`is_active`, `auth_user`.`date_joined`
FROM `auth_user` WHERE `auth_user`.`username` LIKE BINARY %alpha%

1:
https://docs.djangoproject.com/en/2.2/topics/db/sql/#performing-raw-queries

--
Regards
Deep L Sukhwani


On Wed, 25 Sep 2019 at 00:47, leb dev  wrote:

> I now how to use django pagination with ORM django after filtering the
> required data and put in into *pagination div*
>
> *queryset_list = employee.objects.all()*
> *query=request.GET.get("q")*
> *if query:*
> *queryset_list=queryset_list.filter(*
> *  Q(name__icontains=query)|*
> *  Q(father_name__icontains=query)|*
> *  Q(mother_name__icontains=query)|*
> *  Q(content__icontains=query)|*
> *  Q(create_date__icontains=query)*
> *  # Q(user__first_name__contains=query)*
> *).distinct()*
>
>
> *paginator = Paginator(queryset_list, 5)*
> *page_request_var = "page"*
> *page = request.GET.get(page_request_var)*
> *queryset = paginator.get_page(page)*
>
> *context={*
> *"object_list":queryset,*
> *"title":"List Items",*
> *"page_request_var":page_request_var,*
> *}*
> *return render(request,"blog/list.html", context)*
>
>
> the above code is working
>
> my question is how to convert this ORM into raw SQL
>
> i know that i must use LIMIT and OFFSET  in raw SQL  to embedded into
> paginator.
>
>
>
> --
> 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 view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2d44b204-8520-423a-992c-597fd479f856%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/2d44b204-8520-423a-992c-597fd479f856%40googlegroups.com?utm_medium=email_source=footer>
> .
>

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEMqiPc5zqcT%2BaPYSySLCJe22nPC-fCk_RkaTvWvRx5CSqkXQA%40mail.gmail.com.


how to use django pagination with sql query and not ORM

2019-09-24 Thread leb dev
I now how to use django pagination with ORM django after filtering the 
required data and put in into *pagination div*

*queryset_list = employee.objects.all()*
*query=request.GET.get("q")*
*if query:*
*queryset_list=queryset_list.filter(*
*  Q(name__icontains=query)|*
*  Q(father_name__icontains=query)|*
*  Q(mother_name__icontains=query)|*
*  Q(content__icontains=query)|*
*  Q(create_date__icontains=query)*
*  # Q(user__first_name__contains=query)*
*).distinct()*


*paginator = Paginator(queryset_list, 5)*
*page_request_var = "page"*
*page = request.GET.get(page_request_var)*
*queryset = paginator.get_page(page)*

*context={*
*"object_list":queryset,*
*"title":"List Items",*
*"page_request_var":page_request_var,*
*}*
*return render(request,"blog/list.html", context)*


the above code is working 

my question is how to convert this ORM into raw SQL 

i know that i must use LIMIT and OFFSET  in raw SQL  to embedded into 
paginator.



-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2d44b204-8520-423a-992c-597fd479f856%40googlegroups.com.


Django 2.2 mongoengine query pagination performance

2019-08-07 Thread Felix Tillyard
Hi,

We are facing an issue while upgrading from Django 2.1.10 to 2.2.4. We are 
using mongoengine (http://mongoengine.org/) to pull some documents from a 
Mongo database. Following the upgrade performance of this is significantly 
worse.

We ran some profiling using pyspy (https://github.com/benfred/py-spy) which 
produced the attached charts.

Basically it seems like there are many extra function calls, seemingly 
related to pagination, and the control flow here is different following the 
upgrade.

Any ideas / help would be amazing!

Thanks

-- 
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 view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/76590bde-a7bb-4820-bacf-e1a8c3ec13c1%40googlegroups.com.


Re: Novice questions about Pagination syntax and classes in general

2019-06-01 Thread John Bagiliko
I will answer question two. I'm not sure I understand your question 1. The
"objects" is query method of every Django model. You use it to query.
Contacts should be in your models.py and you should import  Contacts in
your views.py before you can use it.

On Sun, Jun 2, 2019, 1:08 AM drone4four  wrote:

> As part of the official Django doc on Pagination
> <https://docs.djangoproject.com/en/2.2/topics/pagination/#using-paginator-in-a-view>,
> take a look at the listing function:
>
> def listing(request):
> contact_list = Contacts.objects.all()
> paginator = Paginator(contact_list, 25) # Show 25 contacts per page
>
>
> My two questions are:
>
>1.
>
>Is it possible to return more than one value when a function is
>assigned to a variable, like at line 3?
>2.
>
>At line 2, is `objects` a method within the Contacts class? If so,
>where is the Contacts class defined? It’s not imported at the top of the
>example views.py also in that Django doc above where I got this code 
> sample.
>
> --
> 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/3540a14b-ef8a-4de3-ad59-858ca1c2a7c4%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/3540a14b-ef8a-4de3-ad59-858ca1c2a7c4%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAC26BE3NXuvsfiOiyF_OAdUXB%3D2nX5S9xEb_OT-8_2v5Zx1cBQ%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Novice questions about Pagination syntax and classes in general

2019-06-01 Thread drone4four


As part of the official Django doc on Pagination 
<https://docs.djangoproject.com/en/2.2/topics/pagination/#using-paginator-in-a-view>,
 
take a look at the listing function:

def listing(request):
contact_list = Contacts.objects.all()
paginator = Paginator(contact_list, 25) # Show 25 contacts per page


My two questions are:

   1. 
   
   Is it possible to return more than one value when a function is assigned 
   to a variable, like at line 3? 
   2. 
   
   At line 2, is `objects` a method within the Contacts class? If so, where 
   is the Contacts class defined? It’s not imported at the top of the example 
   views.py also in that Django doc above where I got this code sample.
   

-- 
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/3540a14b-ef8a-4de3-ad59-858ca1c2a7c4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pagination breaks in ListView after migrating from Django 1.11 to 2.2 with SQLite

2019-04-24 Thread Szabolcs Hodossy
or.py", line 97,
>> in num_pages
>> if self.count == 0 and not self.allow_empty_first_page:
>>   File "(...)\.env\lib\site-packages\django\utils\functional.py", line
>> 80, in __get__
>> res = instance.__dict__[self.name] = self.func(instance)
>>   *File "(...)\.env\lib\site-packages\django\core\paginator.py", line
>> 91, in count*
>> *return c()*
>>   File "(...)\.env\lib\site-packages\django\db\models\query.py", line
>> 392, in count
>> return self.query.get_count(using=self.db)
>>   File "(...)\.env\lib\site-packages\django\db\models\sql\query.py", line
>> 504, in get_count
>> number = obj.get_aggregation(using, ['__count'])['__count']
>>   File "(...)\.env\lib\site-packages\django\db\models\sql\query.py", line
>> 489, in get_aggregation
>> result = compiler.execute_sql(SINGLE)
>>   File "(...)\.env\lib\site-packages\django\db\models\sql\compiler.py",
>> line 1097, in execute_sql
>> cursor.execute(sql, params)
>>   File "(...)\.env\lib\site-packages\django\db\backends\utils.py", line
>> 67, in execute
>> return self._execute_with_wrappers(sql, params, many=False,
>> executor=self._execute)
>>   File "(...)\.env\lib\site-packages\django\db\backends\utils.py", line
>> 76, in _execute_with_wrappers
>> return executor(sql, params, many, context)
>>   File "(...)\.env\lib\site-packages\django\db\backends\utils.py", line
>> 84, in _execute
>> return self.cursor.execute(sql, params)
>>   File "(...)\.env\lib\site-packages\django\db\utils.py", line 89, in
>> __exit__
>> raise dj_exc_value.with_traceback(traceback) from exc_value
>>   File "(...)\.env\lib\site-packages\django\db\backends\utils.py", line
>> 84, in _execute
>> return self.cursor.execute(sql, params)
>>   File "(...)\.env\lib\site-packages\django\db\backends\sqlite3\base.py",
>> line 383, in execute
>> return Database.Cursor.execute(self, query, params)
>> django.db.utils.OperationalError: only a single result allowed for a
>> SELECT that is part of an expression
>>
>> It seems that during pagination some query is made that is not supported
>> by SQLite. Did anybody face the same issue? I am using Python 3.6 with
>> SQLite 3.14.
>>
>> Thanks in advance,
>> Szabolcs
>>
> --
> 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/8b7a762f-4aab-4a18-b160-ee53995e0ef1%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/8b7a762f-4aab-4a18-b160-ee53995e0ef1%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAFp9oi_swqgT3_RArWyRJ_Mfp0z3szOZ7QRznydc2WXOvjHbaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pagination breaks in ListView after migrating from Django 1.11 to 2.2 with SQLite

2019-04-23 Thread Simon Charette
te-packages\django\db\models\sql\compiler.py", 
> line 1097, in execute_sql
> cursor.execute(sql, params)
>   File "(...)\.env\lib\site-packages\django\db\backends\utils.py", line 
> 67, in execute
> return self._execute_with_wrappers(sql, params, many=False, 
> executor=self._execute)
>   File "(...)\.env\lib\site-packages\django\db\backends\utils.py", line 
> 76, in _execute_with_wrappers
> return executor(sql, params, many, context)
>   File "(...)\.env\lib\site-packages\django\db\backends\utils.py", line 
> 84, in _execute
> return self.cursor.execute(sql, params)
>   File "(...)\.env\lib\site-packages\django\db\utils.py", line 89, in 
> __exit__
> raise dj_exc_value.with_traceback(traceback) from exc_value
>   File "(...)\.env\lib\site-packages\django\db\backends\utils.py", line 
> 84, in _execute
> return self.cursor.execute(sql, params)
>   File "(...)\.env\lib\site-packages\django\db\backends\sqlite3\base.py", 
> line 383, in execute
> return Database.Cursor.execute(self, query, params)
> django.db.utils.OperationalError: only a single result allowed for a 
> SELECT that is part of an expression
>
> It seems that during pagination some query is made that is not supported 
> by SQLite. Did anybody face the same issue? I am using Python 3.6 with 
> SQLite 3.14.
>
> Thanks in advance,
> Szabolcs
>

-- 
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/8b7a762f-4aab-4a18-b160-ee53995e0ef1%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Pagination breaks in ListView after migrating from Django 1.11 to 2.2 with SQLite

2019-04-23 Thread hodossy . szabolcs
o\db\backends\utils.py", line 84, 
in _execute
    return self.cursor.execute(sql, params)
  File "(...)\.env\lib\site-packages\django\db\backends\sqlite3\base.py", 
line 383, in execute
return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: only a single result allowed for a SELECT 
that is part of an expression

It seems that during pagination some query is made that is not supported by 
SQLite. Did anybody face the same issue? I am using Python 3.6 with SQLite 
3.14.

Thanks in advance,
Szabolcs

-- 
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/a5a54e8c-d3aa-4eef-b455-82ec15a99e76%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pagination - Not Working

2019-02-19 Thread Aakash Baranwal
Thanks a lot. I worked that out by making the Load More as a clickable
button which when pressed will show the contents.

On Tue, Feb 19, 2019 at 9:00 PM Godson Rapture  wrote:

> Check out simple is better than complex blog. It should have a topic on
> pagination to help you
>
> On Tue, Feb 19, 2019, 9:20 AM Aakash Baranwal 
> wrote:
>
>> Hello,
>>
>> Thanks for offering me your help, but the problem is I can't upload it on
>> internet as I have signed a Non Disclosure Agreement for the project in
>> which I am working, so totally helpless in this case.
>>
>> However I might be able to give a specific portion of what you might need
>> for resolving this issue.
>>
>> I am extremely sorry about this.
>>
>> On Tue, Feb 19, 2019 at 1:38 PM Godson Rapture 
>> wrote:
>>
>>> Can you upload your code on github let me check where your problem is?
>>>
>>> On Tue, Feb 19, 2019, 6:43 AM Siddharth Tamang <
>>> tamangsiddhart...@gmail.com> wrote:
>>>
>>>> Are you trying pagination using JavaScript or Django?
>>>>
>>>> On Mon, Feb 18, 2019 at 11:47 PM Aakash Baranwal 
>>>> wrote:
>>>>
>>>>> Hello Everyone,
>>>>>
>>>>> I am new to Django and working towards developing a web app where 10
>>>>> posts appear at a time with a "Load More" option given at last which when
>>>>> clicked shows the next 10 posts. I am not able to find what is going wrong
>>>>> with the code.
>>>>>
>>>>> Also, it is not showing the character counter for the textbox, so
>>>>> kindly help me with that as well.
>>>>>
>>>>> I am sending the screenshot of the code, pagination.py file.
>>>>>
>>>>> Thank You in advance
>>>>>
>>>>> --
>>>>> 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/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com
>>>>> <https://groups.google.com/d/msgid/django-users/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com?utm_medium=email_source=footer>
>>>>> .
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>>>
>>>>
>>>>
>>>> --
>>>> Thank you
>>>> Siddharth Tamang
>>>> AWS Certified Solutions Architect - Associate
>>>>
>>>> --
>>>> 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/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com?utm_medium=email_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>> --
>>> 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/CAEUEpOTUP_-rdoY8p4%2BfT4%2BTEmCLoSFyLQ1L%3DsdhfPkeHtY3rw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CAEUEpOTUP_-rdoY8p4%2BfT4%2BTEmCLoSFyLQ1L%3Dsdh

Re: Pagination - Not Working

2019-02-19 Thread Aakash Baranwal
It did not work. I tried making it using JavaScript like in websites if you
might have seen when you press the button then only it shows the content or
scrolls down.


On Tue, Feb 19, 2019 at 2:01 PM Siddharth Tamang <
tamangsiddhart...@gmail.com> wrote:

> Can you try this in your views.py?
>
> from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator
>
> views.py
>
> feedTextAll = feedText.objects.order_by('-feedTexDate')
> pages = Paginator(feedTextAll,5)
> pageNum = request.GET.get('page')
> feedtext = pages.get_page(pageNum)
> return render(request, 'index.html',{'feedtext':feedtext})
>
>
> and then in your html file where you want to show paginated records
>
> {% for feedtext in feedtext%}
>
> > 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/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Thank you
> Siddharth Tamang
> AWS Certified Solutions Architect - Associate
>
> --
> 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/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>
 --
 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/CALr9hQ1CRSweCoycg0AfyiwG9LFb%3DZ2NL7oW7BMPuBg8qk%2B2GA%40mail.gmail.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>>
>>>
>>> --
>>> Thank you
>>> Siddharth Tamang
>>> AWS Certified Solutions Architect - Associate
>>>
>>> --
>>> 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/CADBOudtmJpskP-K_5%3D24BOXExeNq0%3DreM4nQZbWLaVrJVo0k8Q%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> 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/CALr9hQ2%2Brp-ih4YCS34PYw3nxFwvvT-EG0DqAdbJ4taLunDHYQ%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Thank you
> Siddharth Tamang
> AWS Certified 

Re: Pagination - Not Working

2019-02-19 Thread Godson Rapture
Check out simple is better than complex blog. It should have a topic on
pagination to help you

On Tue, Feb 19, 2019, 9:20 AM Aakash Baranwal  wrote:

> Hello,
>
> Thanks for offering me your help, but the problem is I can't upload it on
> internet as I have signed a Non Disclosure Agreement for the project in
> which I am working, so totally helpless in this case.
>
> However I might be able to give a specific portion of what you might need
> for resolving this issue.
>
> I am extremely sorry about this.
>
> On Tue, Feb 19, 2019 at 1:38 PM Godson Rapture 
> wrote:
>
>> Can you upload your code on github let me check where your problem is?
>>
>> On Tue, Feb 19, 2019, 6:43 AM Siddharth Tamang <
>> tamangsiddhart...@gmail.com> wrote:
>>
>>> Are you trying pagination using JavaScript or Django?
>>>
>>> On Mon, Feb 18, 2019 at 11:47 PM Aakash Baranwal 
>>> wrote:
>>>
>>>> Hello Everyone,
>>>>
>>>> I am new to Django and working towards developing a web app where 10
>>>> posts appear at a time with a "Load More" option given at last which when
>>>> clicked shows the next 10 posts. I am not able to find what is going wrong
>>>> with the code.
>>>>
>>>> Also, it is not showing the character counter for the textbox, so
>>>> kindly help me with that as well.
>>>>
>>>> I am sending the screenshot of the code, pagination.py file.
>>>>
>>>> Thank You in advance
>>>>
>>>> --
>>>> 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/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com
>>>> <https://groups.google.com/d/msgid/django-users/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com?utm_medium=email_source=footer>
>>>> .
>>>> For more options, visit https://groups.google.com/d/optout.
>>>>
>>>
>>>
>>> --
>>> Thank you
>>> Siddharth Tamang
>>> AWS Certified Solutions Architect - Associate
>>>
>>> --
>>> 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/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>> --
>> 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/CAEUEpOTUP_-rdoY8p4%2BfT4%2BTEmCLoSFyLQ1L%3DsdhfPkeHtY3rw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CAEUEpOTUP_-rdoY8p4%2BfT4%2BTEmCLoSFyLQ1L%3DsdhfPkeHtY3rw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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.goo

Re: Pagination - Not Working

2019-02-19 Thread Siddharth Tamang
Can you try this in your views.py?

from django.core.paginator import EmptyPage, PageNotAnInteger, Paginator

views.py

feedTextAll = feedText.objects.order_by('-feedTexDate')
pages = Paginator(feedTextAll,5)
pageNum = request.GET.get('page')
feedtext = pages.get_page(pageNum)
return render(request, 'index.html',{'feedtext':feedtext})


and then in your html file where you want to show paginated records

{% for feedtext in feedtext%}

 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/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


 --
 Thank you
 Siddharth Tamang
 AWS Certified Solutions Architect - Associate

 --
 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/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com
 
 .
 For more options, visit https://groups.google.com/d/optout.

>>> --
>>> 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/CALr9hQ1CRSweCoycg0AfyiwG9LFb%3DZ2NL7oW7BMPuBg8qk%2B2GA%40mail.gmail.com
>>> 
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> Thank you
>> Siddharth Tamang
>> AWS Certified Solutions Architect - Associate
>>
>> --
>> 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/CADBOudtmJpskP-K_5%3D24BOXExeNq0%3DreM4nQZbWLaVrJVo0k8Q%40mail.gmail.com
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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/CALr9hQ2%2Brp-ih4YCS34PYw3nxFwvvT-EG0DqAdbJ4taLunDHYQ%40mail.gmail.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Thank you
Siddharth Tamang
AWS Certified Solutions Architect - Associate

-- 
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 

Re: Pagination - Not Working

2019-02-19 Thread Aakash Baranwal
Hello,

Thanks for offering me your help, but the problem is I can't upload it on
internet as I have signed a Non Disclosure Agreement for the project in
which I am working, so totally helpless in this case.

However I might be able to give a specific portion of what you might need
for resolving this issue.

I am extremely sorry about this.

On Tue, Feb 19, 2019 at 1:38 PM Godson Rapture  wrote:

> Can you upload your code on github let me check where your problem is?
>
> On Tue, Feb 19, 2019, 6:43 AM Siddharth Tamang <
> tamangsiddhart...@gmail.com> wrote:
>
>> Are you trying pagination using JavaScript or Django?
>>
>> On Mon, Feb 18, 2019 at 11:47 PM Aakash Baranwal 
>> wrote:
>>
>>> Hello Everyone,
>>>
>>> I am new to Django and working towards developing a web app where 10
>>> posts appear at a time with a "Load More" option given at last which when
>>> clicked shows the next 10 posts. I am not able to find what is going wrong
>>> with the code.
>>>
>>> Also, it is not showing the character counter for the textbox, so kindly
>>> help me with that as well.
>>>
>>> I am sending the screenshot of the code, pagination.py file.
>>>
>>> Thank You in advance
>>>
>>> --
>>> 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/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> Thank you
>> Siddharth Tamang
>> AWS Certified Solutions Architect - Associate
>>
>> --
>> 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/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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/CAEUEpOTUP_-rdoY8p4%2BfT4%2BTEmCLoSFyLQ1L%3DsdhfPkeHtY3rw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CAEUEpOTUP_-rdoY8p4%2BfT4%2BTEmCLoSFyLQ1L%3DsdhfPkeHtY3rw%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CALr9hQ2Wvq0woYMTtze_erq65trSxVi-76FXR0HvmHVoCPNZxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pagination - Not Working

2019-02-19 Thread Godson Rapture
Can you upload your code on github let me check where your problem is?

On Tue, Feb 19, 2019, 6:43 AM Siddharth Tamang 
wrote:

> Are you trying pagination using JavaScript or Django?
>
> On Mon, Feb 18, 2019 at 11:47 PM Aakash Baranwal 
> wrote:
>
>> Hello Everyone,
>>
>> I am new to Django and working towards developing a web app where 10
>> posts appear at a time with a "Load More" option given at last which when
>> clicked shows the next 10 posts. I am not able to find what is going wrong
>> with the code.
>>
>> Also, it is not showing the character counter for the textbox, so kindly
>> help me with that as well.
>>
>> I am sending the screenshot of the code, pagination.py file.
>>
>> Thank You in advance
>>
>> --
>> 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/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Thank you
> Siddharth Tamang
> AWS Certified Solutions Architect - Associate
>
> --
> 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/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAEUEpOTUP_-rdoY8p4%2BfT4%2BTEmCLoSFyLQ1L%3DsdhfPkeHtY3rw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pagination - Not Working

2019-02-18 Thread Siddharth Tamang
Please send your views.py. You must have a home page or index page where
you want to paginate records.

On Tue, Feb 19, 2019 at 11:23 AM Aakash Baranwal 
wrote:

> I have also used Ajax with that. It's load more button is not working, it
> is showing the 10 posts which is the limit I set in the beginning, but not
> going beyond that.
>
> On Tue, Feb 19, 2019 at 11:13 AM Siddharth Tamang <
> tamangsiddhart...@gmail.com> wrote:
>
>> Are you trying pagination using JavaScript or Django?
>>
>> On Mon, Feb 18, 2019 at 11:47 PM Aakash Baranwal 
>> wrote:
>>
>>> Hello Everyone,
>>>
>>> I am new to Django and working towards developing a web app where 10
>>> posts appear at a time with a "Load More" option given at last which when
>>> clicked shows the next 10 posts. I am not able to find what is going wrong
>>> with the code.
>>>
>>> Also, it is not showing the character counter for the textbox, so kindly
>>> help me with that as well.
>>>
>>> I am sending the screenshot of the code, pagination.py file.
>>>
>>> Thank You in advance
>>>
>>> --
>>> 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/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com
>>> <https://groups.google.com/d/msgid/django-users/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com?utm_medium=email_source=footer>
>>> .
>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>
>>
>> --
>> Thank you
>> Siddharth Tamang
>> AWS Certified Solutions Architect - Associate
>>
>> --
>> 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/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
> --
> 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/CALr9hQ1CRSweCoycg0AfyiwG9LFb%3DZ2NL7oW7BMPuBg8qk%2B2GA%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALr9hQ1CRSweCoycg0AfyiwG9LFb%3DZ2NL7oW7BMPuBg8qk%2B2GA%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Thank you
Siddharth Tamang
AWS Certified Solutions Architect - Associate

-- 
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/CADBOudtmJpskP-K_5%3D24BOXExeNq0%3DreM4nQZbWLaVrJVo0k8Q%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pagination - Not Working

2019-02-18 Thread Aakash Baranwal
I have also used Ajax with that. It's load more button is not working, it
is showing the 10 posts which is the limit I set in the beginning, but not
going beyond that.

On Tue, Feb 19, 2019 at 11:13 AM Siddharth Tamang <
tamangsiddhart...@gmail.com> wrote:

> Are you trying pagination using JavaScript or Django?
>
> On Mon, Feb 18, 2019 at 11:47 PM Aakash Baranwal 
> wrote:
>
>> Hello Everyone,
>>
>> I am new to Django and working towards developing a web app where 10
>> posts appear at a time with a "Load More" option given at last which when
>> clicked shows the next 10 posts. I am not able to find what is going wrong
>> with the code.
>>
>> Also, it is not showing the character counter for the textbox, so kindly
>> help me with that as well.
>>
>> I am sending the screenshot of the code, pagination.py file.
>>
>> Thank You in advance
>>
>> --
>> 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/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Thank you
> Siddharth Tamang
> AWS Certified Solutions Architect - Associate
>
> --
> 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/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CALr9hQ1CRSweCoycg0AfyiwG9LFb%3DZ2NL7oW7BMPuBg8qk%2B2GA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pagination - Not Working

2019-02-18 Thread Aakash Baranwal
I am trying to do it using Django. I used Django Rest Framework API
Guide-Pagination for reference

On Tue, Feb 19, 2019 at 11:13 AM Siddharth Tamang <
tamangsiddhart...@gmail.com> wrote:

> Are you trying pagination using JavaScript or Django?
>
> On Mon, Feb 18, 2019 at 11:47 PM Aakash Baranwal 
> wrote:
>
>> Hello Everyone,
>>
>> I am new to Django and working towards developing a web app where 10
>> posts appear at a time with a "Load More" option given at last which when
>> clicked shows the next 10 posts. I am not able to find what is going wrong
>> with the code.
>>
>> Also, it is not showing the character counter for the textbox, so kindly
>> help me with that as well.
>>
>> I am sending the screenshot of the code, pagination.py file.
>>
>> Thank You in advance
>>
>> --
>> 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/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com
>> <https://groups.google.com/d/msgid/django-users/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com?utm_medium=email_source=footer>
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>
> --
> Thank you
> Siddharth Tamang
> AWS Certified Solutions Architect - Associate
>
> --
> 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/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CALr9hQ1jGL83EZ5u-FrGmh9c1q6kYNCHUup%3D4CzGhHVi%2BJakSA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pagination - Not Working

2019-02-18 Thread Siddharth Tamang
Are you trying pagination using JavaScript or Django?

On Mon, Feb 18, 2019 at 11:47 PM Aakash Baranwal 
wrote:

> Hello Everyone,
>
> I am new to Django and working towards developing a web app where 10 posts
> appear at a time with a "Load More" option given at last which when clicked
> shows the next 10 posts. I am not able to find what is going wrong with the
> code.
>
> Also, it is not showing the character counter for the textbox, so kindly
> help me with that as well.
>
> I am sending the screenshot of the code, pagination.py file.
>
> Thank You in advance
>
> --
> 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/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com
> <https://groups.google.com/d/msgid/django-users/CALr9hQ02EKRB%3DUjPfgjX1Q1%2BG_QxxBovM7Xv_J9Y-Q%3DiwMLo_A%40mail.gmail.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>


-- 
Thank you
Siddharth Tamang
AWS Certified Solutions Architect - Associate

-- 
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/CADBOudsyrwDg%3DzcG3SgFMVnosOUtym%2BeR3d7UPXEa9GnRz7Opw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django - Paginate with another GET request; not working with just pagination page number

2017-12-06 Thread Jack
I'm building a page with pagination and a filter form (2 GET requests).  If 
the URL includes both pagination and filter results, something like 
`/questions/?page=2_questions=on`, it works fine.  It also works if it 
just has filter results, something like `/questions/?all_questions=on`.

However if it only has the pagination page result, something like 
`/questions/?page=1`, no results are shown.

So I figured I need to do something in the views so that if there is only 
page number in the URL, a default filter will be given.  I know I probably 
need to add something to the Try and Except section of pagination, but I'm 
stumped as the actual code I need to write.


def questions_index(request):

user = request.user
form = QuestionFilterForm(request.GET or None)
question_list = []
if not form.is_bound:
question_list = Question.objects.all().order_by('-date_created')
if form.is_valid():
if form.cleaned_data['all_questions'] | 
(form.cleaned_data['general_questions'] & 
form.cleaned_data['location_all_gta']) == True:
question_list = 
Question.objects.all().order_by('-date_created')
elif form.cleaned_data['location_all_gta'] == True:
question_list += 
Question.objects.filter(question_type=1).order_by('-date_created')
else:
if form.cleaned_data['general_questions'] == True:
question_list += 
Question.objects.filter(question_type=2).order_by('-date_created')
if form.cleaned_data['location_toronto'] == True:
question_list += 
Question.objects.filter(location='1').order_by('-date_created')

paginator = Paginator(question_list, 15)

    # Pagination
page = request.GET.get('page')
try:
questions = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
questions = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. ), deliver last page of 
results.
questions = paginator.page(paginator.num_pages)

### I need to write something here...
except (url has no filter result)  
give default filter 

return render(request, 'questions_index.html', {'questions': 
questions, 'user': user, 'form': form})

-- 
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/2a2f05ae-d71a-419b-9df0-394e1e129fcb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django admin pagination zero based?

2017-11-28 Thread Matemática A3K
On Tue, Nov 28, 2017 at 3:00 PM, Daniel Jewett <d...@solidether.net> wrote:

> I just noticed that the URL get string in my admin app is off by one from
> the auto generated pagination links. It appears that the pagination URLs
> are zero based.
>
> For example if I'm on page 4 of results according to the pagination links,
> the URL looks like '?p=3'
>
> Is this typical?
>

Yup :)


> Any suggestions on how to get them matched up?
>
>
https://github.com/django/django/blob/master/django/contrib/admin/templatetags/admin_list.py#L44



> Thanks!
>
> -Dan J.
>
> --
> 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/a4d14e7f-20d0-49c7-a42d-5535e697c33b%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/a4d14e7f-20d0-49c7-a42d-5535e697c33b%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CA%2BFDnhLSXthvWOPNouiMfDhVprVMzdY1%2BcP5z13ZqTw4iw5-Ug%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django admin pagination zero based?

2017-11-28 Thread Daniel Jewett
I just noticed that the URL get string in my admin app is off by one from 
the auto generated pagination links. It appears that the pagination URLs 
are zero based.

For example if I'm on page 4 of results according to the pagination links, 
the URL looks like '?p=3'

Is this typical? Any suggestions on how to get them matched up?

Thanks!

-Dan J.

-- 
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/a4d14e7f-20d0-49c7-a42d-5535e697c33b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django form needs pagination and saved data - how????

2017-07-31 Thread Jim Illback
Super advice - thanks very much, James! Appreciate your help.

Jim

On Jul 30, 2017, at 5:55 PM, James Schneider 
<jrschneide...@gmail.com<mailto:jrschneide...@gmail.com>> wrote:



On Jul 30, 2017 4:50 PM, "Jim Illback" 
<subaru...@hotmail.com<mailto:subaru...@hotmail.com>> wrote:
Thanks for your reply, James. Appreciate it. BTW, if you check my template, the 
button is within the form tags, but you probably are right on the JS - I don’t 
know JS much at all so just copied other people’s code.

I thought that's how you're supposed to program in JS? Been doing it that way 
for years. ;-)


I may be mistaken, but I think the wizard link below requires a “static” or 
semi-static forms flow path (form1, form2, …, formlast). Generally, when you do 
pagination, there is no preset number of pages - it depends upon the data being 
requested or available. So, I think that option would not work. But, if I’m 
wrong, I’d love to know. Thanks.

By default, yes, it is expecting a known number of steps for more simple 
processes. However, it has all of the hooks necessary to create a fully dynamic 
flow. I did a dynamic flow back when this package was still in Django core, but 
I doubt the process has changed much.


And, as for using Java just so you can use Django, doesn’t that raise the 
obvious question - so why use Django?

I'm not sure what you're referring to here. I don't think that I mentioned Java 
specifically, nor would I have reason to.

Perhaps a mistaken interpretation of my reference to an SPA? This is what I 
meant:

https://en.m.wikipedia.org/wiki/Single-page_application


To try to illustrate that my issue is a common business issue, here’s a 
scenario that is exactly the same situation and one used by almost everyone:

A new car purchase site needs the user to pick the car and model. Then, that 
data stays static throughout the transaction. However, the user might want 
different options (tires, engines, transmission types, etc.). And, those 
options are always too many for one page, so they must be done using 
pagination. When all the options are reviewed - or maybe just one page of 
options or two or… - then the final idea is to show the user the car’s price, 
have all the selections chosen listed out for the user to review, and ask for 
further actions like "do you want to purchase this car?”.

Are these types of business scenarios just not in Django’s wheelhouse?


The level of dynamic content generation required for all of those steps will 
likely be complex, possibly even complicated, for any generic framework to 
handle. The Django formtools can handle the scenario you've listed, but your 
code organization and naming standard will need to be strongly enforced to keep 
the various steps separate.

The workflow you've mentioned isn't necessarily complicated at a high level, 
the step decisions are rather binary. Either a person wants to select different 
tires, or doesn't and accepts the default selection. The code in formtools for 
step selection is usually that simple "if they wanted different tires in a 
previous step, now show them this form for tires", almost a one-liner (for each 
step).

Honestly, the biggest issue will be displaying the multiple pages of options, 
which is somewhat a separate issue.

There are several strategies. You can display multiple form pages across 
multiple requests, keeping the results of each along the way, which complicates 
your back end code. Before the influx of JS and HTML5, this was rather common.

The newer approach is to use JS to pull all of the possible options, and handle 
the UI and pagination within JS, perhaps in a pop up modal window. The data is 
retrieved via an API call, and once a selection is made by the user, either a 
form is executed containing all of the possible options that the user selected.

Datatables.js might be a good option for this, as it can also handle the 
dynamic pagination of options surprisingly well, and plays excellent with 
Bootstrap. Heck, you can probably use DT with either strategy. It would 
definitely ease the logic for the server based form wizard, and likely save you 
a ton of JS scripting for an SPA-like display.

If it were me, I'd investigate Datatables.js with the Bootstrap integration and 
pagination. It's relatively easy to implement (I, like yourself, am averse to 
JS), and provides killer functionality with minimal custom JS (mostly single 
minimal function calls to control ordering of table columns). Once you have 
that working, try integrating the table with a form combined with pagination, I 
think that will be the silver bullet you're looking for.

https://datatables.net<https://datatables.net/>

-James

--
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<mail

Re: Django form needs pagination and saved data - how????

2017-07-30 Thread James Schneider
On Jul 30, 2017 4:50 PM, "Jim Illback" <subaru...@hotmail.com> wrote:

Thanks for your reply, James. Appreciate it. BTW, if you check my template,
the button is within the form tags, but you probably are right on the JS -
I don’t know JS much at all so just copied other people’s code.


I thought that's how you're supposed to program in JS? Been doing it that
way for years. ;-)


I may be mistaken, but I think the wizard link below requires a “static” or
semi-static forms flow path (form1, form2, …, formlast). Generally, when
you do pagination, there is no preset number of pages - it depends upon the
data being requested or available. So, I think that option would not work.
But, if I’m wrong, I’d love to know. Thanks.


By default, yes, it is expecting a known number of steps for more simple
processes. However, it has all of the hooks necessary to create a fully
dynamic flow. I did a dynamic flow back when this package was still in
Django core, but I doubt the process has changed much.


And, as for using Java just so you can use Django, doesn’t that raise the
obvious question - so why use Django?


I'm not sure what you're referring to here. I don't think that I mentioned
Java specifically, nor would I have reason to.

Perhaps a mistaken interpretation of my reference to an SPA? This is what I
meant:

https://en.m.wikipedia.org/wiki/Single-page_application


To try to illustrate that my issue is a common business issue, here’s a
scenario that is exactly the same situation and one used by almost everyone:

A new car purchase site needs the user to pick the car and model. Then,
that data stays static throughout the transaction. However, the user might
want different options (tires, engines, transmission types, etc.). And,
those options are always too many for one page, so they must be done using
pagination. When all the options are reviewed - or maybe just one page of
options or two or… - then the final idea is to show the user the car’s
price, have all the selections chosen listed out for the user to review,
and ask for further actions like "do you want to purchase this car?”.

Are these types of business scenarios just not in Django’s wheelhouse?


The level of dynamic content generation required for all of those steps
will likely be complex, possibly even complicated, for any generic
framework to handle. The Django formtools can handle the scenario you've
listed, but your code organization and naming standard will need to be
strongly enforced to keep the various steps separate.

The workflow you've mentioned isn't necessarily complicated at a high
level, the step decisions are rather binary. Either a person wants to
select different tires, or doesn't and accepts the default selection. The
code in formtools for step selection is usually that simple "if they wanted
different tires in a previous step, now show them this form for tires",
almost a one-liner (for each step).

Honestly, the biggest issue will be displaying the multiple pages of
options, which is somewhat a separate issue.

There are several strategies. You can display multiple form pages across
multiple requests, keeping the results of each along the way, which
complicates your back end code. Before the influx of JS and HTML5, this was
rather common.

The newer approach is to use JS to pull all of the possible options, and
handle the UI and pagination within JS, perhaps in a pop up modal window.
The data is retrieved via an API call, and once a selection is made by the
user, either a form is executed containing all of the possible options that
the user selected.

Datatables.js might be a good option for this, as it can also handle the
dynamic pagination of options surprisingly well, and plays excellent with
Bootstrap. Heck, you can probably use DT with either strategy. It would
definitely ease the logic for the server based form wizard, and likely save
you a ton of JS scripting for an SPA-like display.

If it were me, I'd investigate Datatables.js with the Bootstrap integration
and pagination. It's relatively easy to implement (I, like yourself, am
averse to JS), and provides killer functionality with minimal custom JS
(mostly single minimal function calls to control ordering of table
columns). Once you have that working, try integrating the table with a form
combined with pagination, I think that will be the silver bullet you're
looking for.

https://datatables.net

-James

-- 
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/CA%2Be%2BciV46BEkatAmD9kGX5ugdfmZn7GQsfnjbdte5cey4YxC4w%40mail.gmail.com.
For more o

Re: Django form needs pagination and saved data - how????

2017-07-30 Thread Jim Illback
Thanks for your reply, James. Appreciate it. BTW, if you check my template, the 
button is within the form tags, but you probably are right on the JS - I don’t 
know JS much at all so just copied other people’s code.

I may be mistaken, but I think the wizard link below requires a “static” or 
semi-static forms flow path (form1, form2, …, formlast). Generally, when you do 
pagination, there is no preset number of pages - it depends upon the data being 
requested or available. So, I think that option would not work. But, if I’m 
wrong, I’d love to know. Thanks.

And, as for using Java just so you can use Django, doesn’t that raise the 
obvious question - so why use Django?

To try to illustrate that my issue is a common business issue, here’s a 
scenario that is exactly the same situation and one used by almost everyone:

A new car purchase site needs the user to pick the car and model. Then, that 
data stays static throughout the transaction. However, the user might want 
different options (tires, engines, transmission types, etc.). And, those 
options are always too many for one page, so they must be done using 
pagination. When all the options are reviewed - or maybe just one page of 
options or two or… - then the final idea is to show the user the car’s price, 
have all the selections chosen listed out for the user to review, and ask for 
further actions like "do you want to purchase this car?”.

Are these types of business scenarios just not in Django’s wheelhouse?


On Jul 30, 2017, at 4:51 AM, James Schneider 
<jrschneide...@gmail.com<mailto:jrschneide...@gmail.com>> wrote:



On Jul 28, 2017 5:56 PM, "Jim Illback" 
<subaru...@hotmail.com<mailto:subaru...@hotmail.com>> wrote:
I use the latest versions of Django, python, bootstrap3, and crispy forms for 
this project.

I am trying to present a list of flashcards to a user, sorted by category 
(e.g., Math, Vocabulary, etc.). Then, I want the user to check either the full 
category or individual flashcards to be added to their practice account.

To maintain user inputted checkboxes on multiple pages, I must use POST. But, 
pagination only uses GET. So, a hack on pagination is to wrap the Next/Previous 
buttons in a sub-form and POST using the buttons. This works for pagination, 
but then my normal “I’m done, submit this session and process the updates” 
button - my submit button - does nothing: no GET, no POST, nothing.

How can I enable pagination, multiple screen data accumulation across pages, 
and final submission of the session when complete?

I can't speak to your submit button issue, other than either a piece of 
JavaScript is getting in the way, or the button is located outside of a  
tag.

As for the rest of your troubles, it really sounds like you need a form wizard 
framework, which is what I think you mean by "pagination". Django used to ship 
one as part of the contrib package, but has since moved it out to it's own 
separately maintained app.

https://django-formtools.readthedocs.io/en/latest/wizard.html

It handles keeping data state across multiple form submissions, along with 
dynamic form additions/omissions based on previous steps.

Another option you may consider is developing this process like a 
single-page-application, where all of the data and forms are managed via JS, 
and the final collection of data is submitted as a single blob to the server 
for permanent storage. That's obviously over simplified, but I hope you catch 
my meaning.

-James

--
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<mailto:django-users+unsubscr...@googlegroups.com>.
To post to this group, send email to 
django-users@googlegroups.com<mailto: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/CA%2Be%2BciVCh5oEr3rHLEUB4L%3Dpus_bL8H%2BxpmCev5syjes_XOBDg%40mail.gmail.com<https://groups.google.com/d/msgid/django-users/CA%2Be%2BciVCh5oEr3rHLEUB4L%3Dpus_bL8H%2BxpmCev5syjes_XOBDg%40mail.gmail.com?utm_medium=email_source=footer>.
For more options, visit https://groups.google.com/d/optout.

-- 
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/46BD3ACD-5040-4ABE-9AA0-8BA201E1BDF5%40hotmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django form needs pagination and saved data - how????

2017-07-30 Thread James Schneider
On Jul 28, 2017 5:56 PM, "Jim Illback" <subaru...@hotmail.com> wrote:

I use the latest versions of Django, python, bootstrap3, and crispy forms
for this project.

I am trying to present a list of flashcards to a user, sorted by category
(e.g., Math, Vocabulary, etc.). Then, I want the user to check either the
full category or individual flashcards to be added to their practice
account.

To maintain user inputted checkboxes on multiple pages, I must use POST.
But, pagination only uses GET. So, a hack on pagination is to wrap the
Next/Previous buttons in a sub-form and POST using the buttons. This works
for pagination, but then my normal “I’m done, submit this session and
process the updates” button - my submit button - does nothing: no GET, no
POST, nothing.

*How can I enable pagination, multiple screen data accumulation across
pages, and final submission of the session when complete? *


I can't speak to your submit button issue, other than either a piece of
JavaScript is getting in the way, or the button is located outside of a
 tag.

As for the rest of your troubles, it really sounds like you need a form
wizard framework, which is what I think you mean by "pagination". Django
used to ship one as part of the contrib package, but has since moved it out
to it's own separately maintained app.

https://django-formtools.readthedocs.io/en/latest/wizard.html

It handles keeping data state across multiple form submissions, along with
dynamic form additions/omissions based on previous steps.

Another option you may consider is developing this process like a
single-page-application, where all of the data and forms are managed via
JS, and the final collection of data is submitted as a single blob to the
server for permanent storage. That's obviously over simplified, but I hope
you catch my meaning.

-James

-- 
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/CA%2Be%2BciVCh5oEr3rHLEUB4L%3Dpus_bL8H%2BxpmCev5syjes_XOBDg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Django form needs pagination and saved data - how????

2017-07-28 Thread Jim Illback
I use the latest versions of Django, python, bootstrap3, and crispy forms for 
this project.

I am trying to present a list of flashcards to a user, sorted by category 
(e.g., Math, Vocabulary, etc.). Then, I want the user to check either the full 
category or individual flashcards to be added to their practice account.

To maintain user inputted checkboxes on multiple pages, I must use POST. But, 
pagination only uses GET. So, a hack on pagination is to wrap the Next/Previous 
buttons in a sub-form and POST using the buttons. This works for pagination, 
but then my normal “I’m done, submit this session and process the updates” 
button - my submit button - does nothing: no GET, no POST, nothing.

How can I enable pagination, multiple screen data accumulation across pages, 
and final submission of the session when complete?

Just FYI - for me, session data and hidden forms haven’t worked because the 
data doesn’t come back to the Django server. So, request.POST.get(‘CAT') 
returns NULL even though the web page has a value in the tag ‘CAT’. Session 
data doesn’t work because I can’t get the data to the server.

Here are sub-sections of my code. The “hidden” fields (cat and crd) are visible 
during my testing. They are filled with the IDs of any/all selected categories 
(cat) or flashcards (crd) - comma separated.

Views.py:
class CardsCreate(TemplateView):
template_name = 'sel_cards_add.html'
model = FlashCard

def dispatch(self, request, *args, **kwargs):
print('DISPATCH:')
student_id = kwargs.get('student_id')

try:
flashcards = FlashCard.objects.all().order_by('category', 'front')
except FlashCard.DoesNotExist:
flashcards = None
except Exception as e:
print('type=%s args=%s (%s)' % (type(e), e.args, e))
raise Http404

flashcard_paginator = paginator.Paginator(flashcards, 2)
try:
page = int(request.GET.get('page', '1'))
except ValueError:
page = 1
try:
flashcards = flashcard_paginator.page(page)
except (paginator.EmptyPage, paginator.InvalidPage):
flashcards = flashcard_paginator.page(flashcard_paginator.num_pages)

context = {'flashcards': flashcards, 'id': student_id, 'title': 
'Available Flashcards By Category'}
print('End of DISPATCH:')
return render(request, self.template_name, context)

Template (sel_cards_add.html):
{% extends 'base.html' %}
{% load crispy_forms_tags %}


{% block content %}
{% csrf_token %}


  


{{ title }}
{% for flashcard in flashcards %}
{% ifchanged flashcard.category %}

   Category:  {{ flashcard.category 
}}


  Select?
  Flashcard
  Answer
  Easy Factor

{% endifchanged %}


{{ flashcard.front }}
{{ flashcard.answer }}
{{ flashcard.easy_factor }}

{% empty %}
No flashcards to select 
yet.
{% endfor %}




  



{% if flashcards.has_previous %}


 {% csrf_token %}
Previous

{% endif %}

Page {{ flashcards.number }} of {{ 
flashcards.paginator.num_pages }}

{% if flashcards.has_next %}


 {% csrf_token %}
Next

{% endif %}




Add Selections to 
User
  
Cancel
  
  

http://ajax.googleapis.com/ajax/libs/jquery/2.1.3/jquery.min.js&quot</a>;>


  function chkcat(element) {
  var x = $(element).attr('name');
  var num = x.substring(6,12);
  var categorys = document.getElementById("cat").value;
  var array = strToArray(categorys);
  var checked = document.getElementsByName(x)[0].checked;
  if (checked) {
  if ((array.indexOf(num)) == -1) {
  array.push(num.concat(","));
  }
  }
  else {
  array = valueRemove(num,array);
  }
  document.getElementById("cat").value = array;
  }

  function chkid(element) {
  var x = $(element).attr('name');
  var num = x.substring(5,11);
  var cards = document.getElementById("crd").value;
  var array = strToArray(cards);
  var checked = document.getElementsByName(x)[0].checked;
  if (checked) {
  if ((array.indexOf(num)) == -1) {
  array.push(num.concat(","));
  }
  }
  else {
  array = valueRemove(num,arr

Re: What's the best way to create a reusable pagination template?

2017-02-28 Thread fabrixxm
Yep. My solution is a custom template tag

from django.template.defaulttags import register
from urllib.parse import urlencode

@register.simple_tag(takes_context=True)
def querystringmod(context, *args):
"""Modify current querystring:
 {% querystringmod name value [name value [...]] %}
"""
if (len(args) % 2) !=0:
args.append("")
request = context['request']
current_qs = request.GET.dict()
current_qs.update(dict([ (args[n], args[n+1]) for n in range(0, len(args
), 2) ]))
return urlencode(current_qs)

in template

previous



-- 
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/31ec3240-cee2-41b5-acd0-f4e05d41fb61%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


What's the best way to create a reusable pagination template?

2017-02-27 Thread Frederik Creemers
The code for rendering pagination controls in my app is the same everywhere:

{% if is_paginated %}


{% if page_obj.has_previous %}
Previous
{% endif %}
{% if page_obj.has_next %}
Previous
{% endif %}


{% endif %}


So I'm wondering whether there's a good w to create the href for the 
previous and next buttons based on the current url. I can't just take the 
current url and append "?page=..." to it, since the url may already have a 
"page" parameter and/or other querystring parameters. On stackoverflow, 
I've seen people create a replace_url_parameter template tag, which 
replaces the given parameter by parsing the url, changing the param, and 
rebuilding the url again. I can do this, but this seems like such a common 
task that I'm surprised I can't find any tools to do this in django itself.

If there's an open source project that offers this, I might be interested, 
but I'm not sure if I want to take on an extra dependency just for 
pagination urls.

-- 
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/4cf546e8-a01b-4cea-8f42-92a5dcb0ba3a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Pagination is not showing and also not working

2017-02-14 Thread Kazi Atik


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 Login')
> 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. ), deliver last page of results.
> user_list = paginator.page(paginator.num_pages)
>
> return render(request, 'dashboard.html', {'users': user_list})
>
>
> tempalates/
>
>
> 
> 
> People you may know
> 
> Request
> 
>
>  {% for myuser in userslist %}
>  
>
>
>
>{{ myuser.username }}
>
>
> Add
>
>  
>  {% endfor %}
>
>  
>{% if users.has_previous %}
>  
>{% else %}
>  
>{% endif %}
>{% for i in users.paginator.page_range %}
>  {% if users.number == i %}
>{{ i }}  class="sr-only">(current)
>  {% else %}
>{{ i }}
>  {% endif %}
>{% endfor %}
>{% if users.has_next %}
>  
>{% else %}
>  
>{% endif %}
>  
>
> 
>
>
>
> 
>
> 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.


Pagination is not showing and also not working

2017-02-12 Thread Kazi Atik
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 
Login')
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. ), deliver last page of results.
user_list = paginator.page(paginator.num_pages)

return render(request, 'dashboard.html', {'users': user_list})


tempalates/




People you may know

Request


 {% for myuser in userslist %}
 


   
   {{ myuser.username }}
   
   
Add
   
 
 {% endfor %}

 
   {% if users.has_previous %}
 
   {% else %}
 
   {% endif %}
   {% for i in users.paginator.page_range %}
 {% if users.number == i %}
   {{ i }} (current)
 {% else %}
   {{ i }}
 {% endif %}
   {% endfor %}
   {% if users.has_next %}
 
   {% else %}
 
   {% endif %}
 






i am trying to paginate this but not getting any result


please help me 


whatsapp-8867203481







-- 
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/701eaecf-6c56-441d-bce7-2385786ffad2%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using django pagination or slicing

2016-10-31 Thread ADEWALE ADISA
Thanks fedowag.
On Oct 31, 2016 12:01 PM, "王安刚" <fedo...@gmail.com> wrote:

> hi
> i prefer method 2
>
> you can get all the list from db and store it in redis using zadd
> each time an ajax request comes, you get the data you need using zrange
>
>
> 在 2016年10月31日星期一 UTC+8上午9:05:07,ADEWALE ADISA写道:
>>
>> Hello,
>> Please I need an advice on the best approach to take on the following
>> issues.
>> I have a database table consist of about 1000 record. I need to be
>> displaying like 20 records at a time on a page such that when the user
>> scroll the browser another batches will be append to the browser.
>> Below are the 3 ways am aiming to achieve this:
>>
>> 1. Using django pagination feature.
>>
>> 2. Everytime records need to be appended to the browser , an ajax call is
>> made to the view, then the queryset is slice using appropriate lower and
>> upper band. Then the returned record is appended to the browser.
>>
>> 3. Fetch the whole records from the database and transfer everything to
>> the browser, then JavaScript is now use to slice and be appending as needed.
>>
>> NOTE: The webpage would work like yahoo.com mobile site.
>> Please with approach is the best in term of performance and speed.
>>
>> Thanks.
>>
> --
> 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/022fd700-0edb-419c-9a0d-6e9714229599%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/022fd700-0edb-419c-9a0d-6e9714229599%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAMGzuy-s8X495UAXuQTibAXe9VLumhMvSUEhzo_rb55T4%3DsQ7g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using django pagination or slicing

2016-10-31 Thread ADEWALE ADISA
Thanks very much Ludovic for the advice.
On Oct 31, 2016 9:53 AM, "ludovic coues" <cou...@gmail.com> wrote:

> I would use 1 + 2 from your list.
>
> 3 might work on 1000 record, depending on how much data there is per
> record. But if you grow to more than 10,000 record, the page loading
> can take minutes. I have experienced that issue with two different
> project.
>
> Django pagination by itself won't give you the infinite scroll you are
> expecting. But it should give you an easy interface for slicing the
> data from your db.
>
> An easier way might be class based view. The following exemple create
> a view to a list of object, paginated:
>
> from django.http import JsonResponse
> from django.views.generic import ListView
>
> class ModelListView(ListView):
> model = RecordModel
> paginate_by = 20
>
> It will try to use the template at app/record_model_list.html, the
> context will have the keys paginator, page, is_paginated, object_list.
> You can override the method render_to_response to return a json
> response.
> The documentation on ListView is at [1] and there is an exemple for
> returning JsonResponse at [2]
>
>
> [1] https://docs.djangoproject.com/en/1.10/topics/class-
> based-views/generic-display/
> [2] https://docs.djangoproject.com/en/1.10/topics/class-
> based-views/mixins/#more-than-just-html
>
>
>
>
> 2016-10-31 2:04 GMT+01:00 ADEWALE ADISA <solixzsys...@gmail.com>:
> > Hello,
> > Please I need an advice on the best approach to take on the following
> > issues.
> > I have a database table consist of about 1000 record. I need to be
> > displaying like 20 records at a time on a page such that when the user
> > scroll the browser another batches will be append to the browser.
> > Below are the 3 ways am aiming to achieve this:
> >
> > 1. Using django pagination feature.
> >
> > 2. Everytime records need to be appended to the browser , an ajax call is
> > made to the view, then the queryset is slice using appropriate lower and
> > upper band. Then the returned record is appended to the browser.
> >
> > 3. Fetch the whole records from the database and transfer everything to
> the
> > browser, then JavaScript is now use to slice and be appending as needed.
> >
> > NOTE: The webpage would work like yahoo.com mobile site.
> > Please with approach is the best in term of performance and speed.
> >
> > Thanks.
> >
> > --
> > 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/CAMGzuy8cK7ueHGPwuCjbrV-
> SdfZwkYYhg7_t7-Dmmt%3D6g787YA%40mail.gmail.com.
> > For more options, visit https://groups.google.com/d/optout.
>
>
>
> --
>
> Cordialement, Coues Ludovic
> +336 148 743 42
>
> --
> 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/CAEuG%2BTaPWphYQAwa9-rPW5VZ93yyA3kL%
> 3Dz8JAecdLRMiKdjihA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CAMGzuy_Tu7mdL4RTvNGWY%3Dm5PL0ttT4wv9QKeMfiLqd43MiaVw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using django pagination or slicing

2016-10-31 Thread 王安刚
hi 
i prefer method 2

you can get all the list from db and store it in redis using zadd
each time an ajax request comes, you get the data you need using zrange


在 2016年10月31日星期一 UTC+8上午9:05:07,ADEWALE ADISA写道:
>
> Hello,
> Please I need an advice on the best approach to take on the following 
> issues.
> I have a database table consist of about 1000 record. I need to be 
> displaying like 20 records at a time on a page such that when the user 
> scroll the browser another batches will be append to the browser. 
> Below are the 3 ways am aiming to achieve this:
>
> 1. Using django pagination feature.
>
> 2. Everytime records need to be appended to the browser , an ajax call is 
> made to the view, then the queryset is slice using appropriate lower and 
> upper band. Then the returned record is appended to the browser.
>
> 3. Fetch the whole records from the database and transfer everything to 
> the browser, then JavaScript is now use to slice and be appending as needed.
>
> NOTE: The webpage would work like yahoo.com mobile site.
> Please with approach is the best in term of performance and speed.
>
> Thanks.
>

-- 
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/022fd700-0edb-419c-9a0d-6e9714229599%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using django pagination or slicing

2016-10-31 Thread ludovic coues
I would use 1 + 2 from your list.

3 might work on 1000 record, depending on how much data there is per
record. But if you grow to more than 10,000 record, the page loading
can take minutes. I have experienced that issue with two different
project.

Django pagination by itself won't give you the infinite scroll you are
expecting. But it should give you an easy interface for slicing the
data from your db.

An easier way might be class based view. The following exemple create
a view to a list of object, paginated:

from django.http import JsonResponse
from django.views.generic import ListView

class ModelListView(ListView):
model = RecordModel
paginate_by = 20

It will try to use the template at app/record_model_list.html, the
context will have the keys paginator, page, is_paginated, object_list.
You can override the method render_to_response to return a json
response.
The documentation on ListView is at [1] and there is an exemple for
returning JsonResponse at [2]


[1] 
https://docs.djangoproject.com/en/1.10/topics/class-based-views/generic-display/
[2] 
https://docs.djangoproject.com/en/1.10/topics/class-based-views/mixins/#more-than-just-html




2016-10-31 2:04 GMT+01:00 ADEWALE ADISA <solixzsys...@gmail.com>:
> Hello,
> Please I need an advice on the best approach to take on the following
> issues.
> I have a database table consist of about 1000 record. I need to be
> displaying like 20 records at a time on a page such that when the user
> scroll the browser another batches will be append to the browser.
> Below are the 3 ways am aiming to achieve this:
>
> 1. Using django pagination feature.
>
> 2. Everytime records need to be appended to the browser , an ajax call is
> made to the view, then the queryset is slice using appropriate lower and
> upper band. Then the returned record is appended to the browser.
>
> 3. Fetch the whole records from the database and transfer everything to the
> browser, then JavaScript is now use to slice and be appending as needed.
>
> NOTE: The webpage would work like yahoo.com mobile site.
> Please with approach is the best in term of performance and speed.
>
> Thanks.
>
> --
> 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/CAMGzuy8cK7ueHGPwuCjbrV-SdfZwkYYhg7_t7-Dmmt%3D6g787YA%40mail.gmail.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Coues Ludovic
+336 148 743 42

-- 
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/CAEuG%2BTaPWphYQAwa9-rPW5VZ93yyA3kL%3Dz8JAecdLRMiKdjihA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Using django pagination or slicing

2016-10-30 Thread ADEWALE ADISA
Hello,
Please I need an advice on the best approach to take on the following
issues.
I have a database table consist of about 1000 record. I need to be
displaying like 20 records at a time on a page such that when the user
scroll the browser another batches will be append to the browser.
Below are the 3 ways am aiming to achieve this:

1. Using django pagination feature.

2. Everytime records need to be appended to the browser , an ajax call is
made to the view, then the queryset is slice using appropriate lower and
upper band. Then the returned record is appended to the browser.

3. Fetch the whole records from the database and transfer everything to the
browser, then JavaScript is now use to slice and be appending as needed.

NOTE: The webpage would work like yahoo.com mobile site.
Please with approach is the best in term of performance and speed.

Thanks.

-- 
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/CAMGzuy8cK7ueHGPwuCjbrV-SdfZwkYYhg7_t7-Dmmt%3D6g787YA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: django pagination

2016-01-26 Thread Xristos Xristoou
i find solutio 
using https://docs.djangoproject.com/en/1.9/topics/pagination/ thnX

Τη Τρίτη, 26 Ιανουαρίου 2016 - 3:10:06 μ.μ. UTC+2, ο χρήστης pa xapy έγραψε:
>
> you want to paginate both querysets at the same page? 
> i believe it's a pretty strange idea and if so, you should think how to 
> refactor it
> if you want only paginate posts, i'll recommend you to use 
> django-pagination app of some sort, it's can be used in template
>
> On Monday, January 25, 2016 at 5:16:31 PM UTC+3, Xristos Xristoou wrote:
>>
>> i want to using Paginator in my main page for my post list. i see docs 
>> and examples for that but i thing my problem is a specific, because on my 
>> view i have two Querys not one.
>>
>>
>> def index(request):
>> return render_to_response("blog/posts_list.html", {
>> 'categories': Category.objects.all(),
>> 'posts': 
>> Posts.objects.filter(publisheddate__lte=timezone.now()).order_by('-publisheddate')
>> })
>>
>>
>> any idea how to use Paginator on my view ?
>>
>>

-- 
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/58103c46-0740-48c8-8340-0a957c60c4da%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django pagination

2016-01-26 Thread Xristos Xristoou
i foolow the steps but i have again error my new view :

def index(request):
try:
page = request.GET.get('page', 1),
except PageNotAnInteger:
page = 1,
objects = ['john', 'edward', 'josh', 'frank']
p = Paginator(objects,request=request)
people = p.page(page)
return render_to_response("blog/movies_list.html", {
'ranking' : Movies.objects.all().order_by('-rating')[:3],
'likes': Movies.objects.all().order_by('-like')[:3],
'categories': Category.objects.all(),
'people':people,
'posts': 
Movies.objects.filter(publisheddate__lte=timezone.now()).order_by('-publisheddate')
})


first i dont understand how is the objects

the show error in the line :p = Paginator(objects,request=request) any idea ?

-- 
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/b914061b-bf4a-4a36-a3df-ca97a5ed1473%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django pagination

2016-01-26 Thread Xristos Xristoou
that method is Confusing,i try to understand,i create new view or i work 
with current?i not understand it the using 'people' and object on they view

Τη Δευτέρα, 25 Ιανουαρίου 2016 - 4:16:31 μ.μ. UTC+2, ο χρήστης Xristos 
Xristoou έγραψε:
>
> i want to using Paginator in my main page for my post list. i see docs and 
> examples for that but i thing my problem is a specific, because on my view 
> i have two Querys not one.
>
>
> def index(request):
> return render_to_response("blog/posts_list.html", {
> 'categories': Category.objects.all(),
> 'posts': 
> Posts.objects.filter(publisheddate__lte=timezone.now()).order_by('-publisheddate')
> })
>
>
> any idea how to use Paginator on my view ?
>
>

-- 
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/e4b4344d-5e96-47c7-aff1-74e81b7eb374%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django pagination

2016-01-26 Thread pa xapy
are you using python 3?
that's actually what i talking about - it's too old
try another one, like 
this https://github.com/jamespacileo/django-pure-pagination - follow 
the instructions and i hope you'll be fine

On Tuesday, January 26, 2016 at 5:09:29 PM UTC+3, Xristos Xristoou wrote:
>
> i follow the simpe steps but i take error invalid syntax 
> (pagination_tags.py, line 225)
>
> Τη Δευτέρα, 25 Ιανουαρίου 2016 - 4:16:31 μ.μ. UTC+2, ο χρήστης Xristos 
> Xristoou έγραψε:
>>
>> i want to using Paginator in my main page for my post list. i see docs 
>> and examples for that but i thing my problem is a specific, because on my 
>> view i have two Querys not one.
>>
>>  
>>
> def index(request):
>> return render_to_response("blog/posts_list.html", {
>> 'categories': Category.objects.all(),
>> 'posts': 
>> Posts.objects.filter(publisheddate__lte=timezone.now()).order_by('-publisheddate')
>> })
>>
>>
>> any idea how to use Paginator on my view ?
>>
>>

-- 
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/6f57db3c-68e5-40f2-b35a-22d7e43b8355%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django pagination

2016-01-26 Thread Xristos Xristoou
i follow the simpe steps but i take error invalid syntax 
(pagination_tags.py, line 225)

Τη Δευτέρα, 25 Ιανουαρίου 2016 - 4:16:31 μ.μ. UTC+2, ο χρήστης Xristos 
Xristoou έγραψε:
>
> i want to using Paginator in my main page for my post list. i see docs and 
> examples for that but i thing my problem is a specific, because on my view 
> i have two Querys not one.
>
>
> def index(request):
> return render_to_response("blog/posts_list.html", {
> 'categories': Category.objects.all(),
> 'posts': 
> Posts.objects.filter(publisheddate__lte=timezone.now()).order_by('-publisheddate')
> })
>
>
> any idea how to use Paginator on my view ?
>
>

-- 
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/e77feb8e-adfd-4468-ab84-80a5d9523c5f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django pagination

2016-01-26 Thread Xristos Xristoou
thnx you i try to use that now

Τη Δευτέρα, 25 Ιανουαρίου 2016 - 4:16:31 μ.μ. UTC+2, ο χρήστης Xristos 
Xristoou έγραψε:
>
> i want to using Paginator in my main page for my post list. i see docs and 
> examples for that but i thing my problem is a specific, because on my view 
> i have two Querys not one.
>
>
> def index(request):
> return render_to_response("blog/posts_list.html", {
> 'categories': Category.objects.all(),
> 'posts': 
> Posts.objects.filter(publisheddate__lte=timezone.now()).order_by('-publisheddate')
> })
>
>
> any idea how to use Paginator on my view ?
>
>

-- 
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/975e3703-a73a-4057-aaf4-341c7ae724d4%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django pagination

2016-01-26 Thread pa xapy
are you familiar with the pip utility?
if not, i highly recommend to read about 
it https://pip.pypa.io/en/stable/quickstart/
if yes, you should know that you can install any application with pip 
install package_name
and how set it up with django - it's better if you read in instructions for 
package you choose

but i'm afraid that this particular app is too old and you can experience 
some troubles with it
anyways, you can try: pip install django-pagination

On Tuesday, January 26, 2016 at 4:44:05 PM UTC+3, Xristos Xristoou wrote:
>
> one more question how to install this ?autopagination ?i dont see anything
>
> Τη Δευτέρα, 25 Ιανουαρίου 2016 - 4:16:31 μ.μ. UTC+2, ο χρήστης Xristos 
> Xristoou έγραψε:
>>
>> i want to using Paginator in my main page for my post list. i see docs 
>> and examples for that but i thing my problem is a specific, because on my 
>> view i have two Querys not one.
>>
>>
>> def index(request):
>> return render_to_response("blog/posts_list.html", {
>> 'categories': Category.objects.all(),
>> 'posts': 
>> Posts.objects.filter(publisheddate__lte=timezone.now()).order_by('-publisheddate')
>> })
>>
>>
>> any idea how to use Paginator on my view ?
>>
>>

-- 
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/9a491e58-4f39-4ad0-b502-c1a52579855c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django pagination

2016-01-26 Thread Xristos Xristoou
one more question how to install this ?autopagination ?i dont see anything

Τη Δευτέρα, 25 Ιανουαρίου 2016 - 4:16:31 μ.μ. UTC+2, ο χρήστης Xristos 
Xristoou έγραψε:
>
> i want to using Paginator in my main page for my post list. i see docs and 
> examples for that but i thing my problem is a specific, because on my view 
> i have two Querys not one.
>
>
> def index(request):
> return render_to_response("blog/posts_list.html", {
> 'categories': Category.objects.all(),
> 'posts': 
> Posts.objects.filter(publisheddate__lte=timezone.now()).order_by('-publisheddate')
> })
>
>
> any idea how to use Paginator on my view ?
>
>

-- 
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/20c91b88-4893-4bb1-82a0-c14ddf0b0050%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django pagination

2016-01-26 Thread pa xapy
you can read the usage doc i sent linked, but yes - you don't need to do 
anything with you queryset in view only pass it to template

On Tuesday, January 26, 2016 at 4:39:17 PM UTC+3, Xristos Xristoou wrote:
>
> if i use {autopagination} i dont need quyre on my view ?
>
> Τη Δευτέρα, 25 Ιανουαρίου 2016 - 4:16:31 μ.μ. UTC+2, ο χρήστης Xristos 
> Xristoou έγραψε:
>>
>> i want to using Paginator in my main page for my post list. i see docs 
>> and examples for that but i thing my problem is a specific, because on my 
>> view i have two Querys not one.
>>
>>
>> def index(request):
>> return render_to_response("blog/posts_list.html", {
>> 'categories': Category.objects.all(),
>> 'posts': 
>> Posts.objects.filter(publisheddate__lte=timezone.now()).order_by('-publisheddate')
>> })
>>
>>
>> any idea how to use Paginator on my view ?
>>
>>

-- 
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/82411c31-5085-4b0f-955c-232f36ff7288%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django pagination

2016-01-26 Thread Xristos Xristoou
if i use {autopagination} i dont need quyre on my view ?

Τη Δευτέρα, 25 Ιανουαρίου 2016 - 4:16:31 μ.μ. UTC+2, ο χρήστης Xristos 
Xristoou έγραψε:
>
> i want to using Paginator in my main page for my post list. i see docs and 
> examples for that but i thing my problem is a specific, because on my view 
> i have two Querys not one.
>
>
> def index(request):
> return render_to_response("blog/posts_list.html", {
> 'categories': Category.objects.all(),
> 'posts': 
> Posts.objects.filter(publisheddate__lte=timezone.now()).order_by('-publisheddate')
> })
>
>
> any idea how to use Paginator on my view ?
>
>

-- 
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/6ec5fa3d-9f45-4a0a-8ee6-3ef44893a24d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django pagination

2016-01-26 Thread pa xapy
if you'll decide to use some app for pagination, you can do it in template, 
like 
so https://github.com/ericflo/django-pagination/blob/master/docs/usage.txt 
({% autopaginate posts 10 %})
or you can choose one of 
these https://www.djangopackages.com/grids/g/pagination/
there is no actual need to do it in view
but still, if you want to only paginate posts, I can't see a problem at all

On Tuesday, January 26, 2016 at 4:27:58 PM UTC+3, Xristos Xristoou wrote:
>
> can you show me one examples with my view ?
>
> Τη Δευτέρα, 25 Ιανουαρίου 2016 - 4:16:31 μ.μ. UTC+2, ο χρήστης Xristos 
> Xristoou έγραψε:
>>
>> i want to using Paginator in my main page for my post list. i see docs 
>> and examples for that but i thing my problem is a specific, because on my 
>> view i have two Querys not one.
>>
>>
>> def index(request):
>> return render_to_response("blog/posts_list.html", {
>> 'categories': Category.objects.all(),
>> 'posts': 
>> Posts.objects.filter(publisheddate__lte=timezone.now()).order_by('-publisheddate')
>> })
>>
>>
>> any idea how to use Paginator on my view ?
>>
>>

-- 
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/5d3687ed-64f8-43ce-a20c-43c45e957633%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django pagination

2016-01-26 Thread Xristos Xristoou
can you show me one examples with my view ?

Τη Δευτέρα, 25 Ιανουαρίου 2016 - 4:16:31 μ.μ. UTC+2, ο χρήστης Xristos 
Xristoou έγραψε:
>
> i want to using Paginator in my main page for my post list. i see docs and 
> examples for that but i thing my problem is a specific, because on my view 
> i have two Querys not one.
>
>
> def index(request):
> return render_to_response("blog/posts_list.html", {
> 'categories': Category.objects.all(),
> 'posts': 
> Posts.objects.filter(publisheddate__lte=timezone.now()).order_by('-publisheddate')
> })
>
>
> any idea how to use Paginator on my view ?
>
>

-- 
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/12b31dc3-77ca-4e32-b340-8d0019b9f580%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: django pagination

2016-01-26 Thread pa xapy
you want to paginate both querysets at the same page? 
i believe it's a pretty strange idea and if so, you should think how to 
refactor it
if you want only paginate posts, i'll recommend you to use 
django-pagination app of some sort, it's can be used in template

On Monday, January 25, 2016 at 5:16:31 PM UTC+3, Xristos Xristoou wrote:
>
> i want to using Paginator in my main page for my post list. i see docs and 
> examples for that but i thing my problem is a specific, because on my view 
> i have two Querys not one.
>
>
> def index(request):
> return render_to_response("blog/posts_list.html", {
> 'categories': Category.objects.all(),
> 'posts': 
> Posts.objects.filter(publisheddate__lte=timezone.now()).order_by('-publisheddate')
> })
>
>
> any idea how to use Paginator on my view ?
>
>

-- 
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/6ef8c4c5-4354-4c97-b0a0-9c28f49ab773%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


django pagination

2016-01-25 Thread Xristos Xristoou
i want to using Paginator in my main page for my post list. i see docs and 
examples for that but i thing my problem is a specific, because on my view 
i have two Querys not one.


def index(request):
return render_to_response("blog/posts_list.html", {
'categories': Category.objects.all(),
'posts': 
Posts.objects.filter(publisheddate__lte=timezone.now()).order_by('-publisheddate')
})


any idea how to use Paginator on my view ?

-- 
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/8e0b5497-e3b3-4e62-b698-180f68e46a56%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: how pass get parameter django bootstrap pagination

2015-03-06 Thread Collin Anderson
Hi,

If you have the request context processor installed, you can do this:

{% bootstrap_paginate object_list range=request.GET.range %}

Collin

On Thursday, March 5, 2015 at 4:35:33 AM UTC-5, SHINTO PETER wrote:
>
>  {% load bootstrap_pagination %}
>   {% bootstrap_paginate object_list range=10 %}
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c135d389-2bac-46b1-8816-287f35fa20cd%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


how pass get parameter django bootstrap pagination

2015-03-05 Thread SHINTO PETER
 {% load bootstrap_pagination %}
  {% bootstrap_paginate object_list range=10 %}

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b14a8f31-785b-429b-bd4a-e7518a7b851a%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: How can I implement Ajax pagination without side modules like endless-pagination

2014-10-06 Thread Collin Anderson
copy/pasting from a recent website I worked on for an example...
we actually just had a "load more" button without showing the total number 
of pages. Not saying you should do it this way, but it's one possible way.

def listing(request):
new_list = NewPost.objects.all()
if request.GET.get('before'):
new_list = new_list.filter(post_date__lte=request.GET.get('before'))
num_posts = 6
items = list(new_list[:num_posts + 1])
return render('list.html', {'news': items[:num_posts], 'more': items[
num_posts:]})



{% for item in news %}
{{ item }} etc 
{% endfor %}
{% if more %}
Load More
{% end if %}


 // assuming jQuery is on the page
$(document).on('click', '.js-load-more', function(e){
e.preventDefault();
var more_link = this;
$.get(this.href, function(data){
$(more_link).replaceWith($($.parseHTML(data)).find('.js-items').
children());
})
})


-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0757add7-a622-4ddf-97a7-c91b89b75fee%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


How can I implement Ajax pagination without side modules like endless-pagination

2014-10-06 Thread Artie
I need to make ajax pagination in my project and not allowed to use side 
modules like dajax or endless-pagination.

Code in my views.py is following
def listing(request):
news_list = NewPost.objects.all()
paginator = Paginator(news_list, 2)

page = request.GET.get('page')
try:
news = paginator.page(page)
except PageNotAnInteger:
news = paginator.page(1)
except EmptyPage:
news = paginator.page(paginator.num_pages)

return render_to_response('list.html', {"news": news})
Need to load new pages with AJAX

How it should be done?

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/059aff43-9578-4265-8cd0-21e900b83d97%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


problem with django daj pagination

2014-09-24 Thread Артём Мутерко
I'm trying to set up dajax pagination in py app. The problem is when I add 
import dajaxwebsite.examples.views

to views.py
My css stop working.
Maybe I should use another ajax pagination plugin? like endless-pagination

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2d16809c-2e54-48a0-8fd2-7807abe749ca%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: muliple pagination on same page

2014-08-27 Thread hardik sottany
Sir I will mail my appointment modal please give me a sample solution
On Aug 27, 2014 8:36 PM, "Camilo Torres"  wrote:

> This is basically a DB query issue. Follow these general directions:
>
> 1. In your page add a form with a select with the filtering options.
> 2. In your view, instead of getting all the instance of your model, filter
> by the selected option.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/6Q9-DElNxPU/unsubscribe.
> To unsubscribe from this group and all its topics, 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/ff014ba5-d10c-4a54-9039-799794278a00%40googlegroups.com
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMboYZJgddc%3DKPAzSkANmyR1qs5dzu23RvBiir0ZHgKEfqTofw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: muliple pagination on same page

2014-08-27 Thread Camilo Torres
This is basically a DB query issue. Follow these general directions:

1. In your page add a form with a select with the filtering options.
2. In your view, instead of getting all the instance of your model, filter by 
the selected option.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ff014ba5-d10c-4a54-9039-799794278a00%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: muliple pagination on same page

2014-08-25 Thread hardik sottany
I want to do pagination using filter on same page which show all on same
page
On Aug 25, 2014 7:26 PM, "Collin Anderson" <cmawebs...@gmail.com> wrote:

> What do you have so far?
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/6Q9-DElNxPU/unsubscribe.
> To unsubscribe from this group and all its topics, 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b5f93597-9e04-41d0-8f3e-b1c424f22d2f%40googlegroups.com
> <https://groups.google.com/d/msgid/django-users/b5f93597-9e04-41d0-8f3e-b1c424f22d2f%40googlegroups.com?utm_medium=email_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMboYZK03Dk_Uga%3DEDgE3agTfAzSbZJwJ1HdiZYNjePnp1LH0g%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: muliple pagination on same page

2014-08-25 Thread hardik sottany
I have model with date time pk appointment details
On Aug 25, 2014 7:26 PM, "Collin Anderson"  wrote:

> What do you have so far?
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/6Q9-DElNxPU/unsubscribe.
> To unsubscribe from this group and all its topics, 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/b5f93597-9e04-41d0-8f3e-b1c424f22d2f%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAMboYZL1k%2BBv4j6%2Bi0aymEPN5VX3E%2B%3DNAEgkhS270471EoeLAg%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: muliple pagination on same page

2014-08-25 Thread Collin Anderson
What do you have so far?

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/b5f93597-9e04-41d0-8f3e-b1c424f22d2f%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


muliple pagination on same page

2014-08-25 Thread hardik sottany
hello friend 
i want to use pagination for today appointment tommorows appoint and past 
appointment can any1 help me out in quite greater need

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c9fd5d4a-acd4-4a00-84cf-72abdfbfdbcf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Casting a raw query set as a list for pagination

2014-04-26 Thread Matt Buck
I've created a paginator for RawQuerySets. 
 https://github.com/seamusmb/django-paginator-rawqueryset

On Tuesday, March 26, 2013 5:51:41 AM UTC-4, chambe...@gmail.com wrote:
>
> I'm trying to implement Django's built in pagination feature with a raw 
> query set. I've researched the issue and the answer is I need to cast my 
> set as a list. Something like this:
>
> paginator = Paginator(refg, 100) # Show 100 contacts per page
> paginator._count = len(list(refg))
>
> From my understanding, setting the count field for the paginator should 
> prevent Django from trying to get the size of my raw set, but this is not the 
> case.  I'm still getting the "RawQuerySet has no len() operation" error.  
> I've attched the relevant code from my views.py and my template.  
>
> Can I get some advice as to how I can fix this error?
>
>
> views.py
> refg = RefGene.objects.raw(qrefg) 
>
> paginator = Paginator(refg, 100) # Show 100 contacts per page 
> paginator._count = len(list(refg)) 
>
> # using django's generated forms 
> c = RequestContext(request, { 
> "refg": refg, ... }) 
>
> return HttpResponse(t.render(c)) 
>
>
> template
>
> {% autopaginate refg %}
> {% for r in refg %}
>
> 
> {{ r.data}}
> {{ r.loc}}
> 
>
> {% endfor %}
> {% paginate %}
>
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/86cd1c6d-5e2d-409c-8ce7-f911c61fe856%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Django Pagination

2013-10-03 Thread Hélio Miranda
Thanks for the help guys, I managed to solve, so I did:

* queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 2)*
*
*
*try: *
* page = int(request.POST.get('page','1')) *
*except ValueError: *
* page = 1 *
*try: *
*results = paginator.page(page) *
*except (EmptyPage, InvalidPage): *
*results = paginator.page(paginator.num_pages) *
*return HttpResponse(json.dumps([item.get_json() for item in 
results.object_list]) , content_type='application/json')*

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/8b0e5b6c-6337-4ea5-8020-535377657b15%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Hélio Miranda
thus still giving the same error

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0a0a64c2-c573-4803-a192-fee936e0d65b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Roberto López López
On 10/03/2013 04:13 PM, Roberto López López wrote:
> *return HttpResponse(json.dumps([players]) ,
> content_type='application/json')*
better without the square brackets

*return HttpResponse(json.dumps(players) ,
content_type='application/json')*

-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/524D7F41.7070003%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Hélio Miranda
doing so:
*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 2)*
*
*
*page = request.GET.get('page')*
*try:*
*players = paginator.page(page)*
*except PageNotAnInteger:*
*players = paginator.page(1)*
*except EmptyPage:*
*players = paginator.page(paginator.num_pages)*
*return HttpResponse(json.dumps(players) , 
content_type='application/json')*

Gives the following error:

 is not JSON serializable


Testing like this:*queryset = Player.objects.filter(name=namepost)
paginator = Paginator(queryset, 2)
  return HttpResponse(json.dumps([item.get_json() for item in 
paginator.page(1)]) , content_type='application/json')*

works, but I have to put the page number of manually

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7c2ad980-05f2-408e-8049-96c5900fb4f9%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Roberto López López
Try this (I have not tried the code myself, but I think that it should
work):

*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 2)
page = request.GET.get('page')
try:
players = paginator.page(page)
except PageNotAnInteger:
players = paginator.page(1)
except EmptyPage:
players = paginator.page(paginator.num_pages)
*
*return HttpResponse(json.dumps([players]) ,
content_type='application/json')*



On 10/03/2013 04:07 PM, Hélio Miranda wrote:
> Already got it, I did so:
> *queryset = Player.objects.filter(name=namepost)*
> *paginator = Paginator(queryset, 2)*
> *return HttpResponse(json.dumps([item.get_json() for item in
> paginator.object_list]) , content_type='application/json')*
>
> But I return all the records ... I should not return only 2?
> -- 
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e7e37ad2-281c-41f4-a0b9-b333294fe1b8%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/524D7B79.4090400%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Roberto López López
Better to say:

*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 2)
page = request.GET.get('page')
try:
players = paginator.page(page)
except PageNotAnInteger:
players = paginator.page(1)
except EmptyPage:
players = paginator.page(paginator.num_pages)
*
*return HttpResponse(json.dumps(players) ,
content_type='application/json')*


On 10/03/2013 04:07 PM, Hélio Miranda wrote:
> Already got it, I did so:
> *queryset = Player.objects.filter(name=namepost)*
> *paginator = Paginator(queryset, 2)*
> *return HttpResponse(json.dumps([item.get_json() for item in
> paginator.object_list]) , content_type='application/json')*
>
> But I return all the records ... I should not return only 2?
> -- 
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/e7e37ad2-281c-41f4-a0b9-b333294fe1b8%40googlegroups.com.
> For more options, visit https://groups.google.com/groups/opt_out.


-- 

Roberto López López
System Developer
Parallab, Uni Computing
+47 55584091

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/524D7BB6.1050502%40uni.no.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Hélio Miranda
Already got it, I did so:
*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 2)*
*return HttpResponse(json.dumps([item.get_json() for item in 
paginator.object_list]) , content_type='application/json')*

But I return all the records ... I should not return only 2?

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/e7e37ad2-281c-41f4-a0b9-b333294fe1b8%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Hélio Miranda
Already got it, I did so:
*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 1)*
*return HttpResponse(json.dumps([item.get_json() for item in 
paginator.object_list]) , content_type='application/json')*

But I return all the records ... I should not return only 2?

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/883c9f30-980a-4d9b-b116-5b5b9da04b5d%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Hélio Miranda
I'm doing this:
*queryset = Player.objects.filter(name=namepost)*
*paginator = Paginator(queryset, 20)*
*return json.dumps([item.get_json() for item in paginator.object_list])*

And my Document is thus:
http://plnkr.co/edit/FHH2hZh26OiLMKTk2ToO

But it gives me the following error:

'str' object has no attribute 'status_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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/29b801fe-644c-42b4-85aa-733de74c341a%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Django Pagination

2013-10-03 Thread Tom Christie
Hi Hélio,

It looks like you're applying pagination to the rendered JSON string itself.
You want to be paginating the queryset itself.

queryset = Player.objects.filter(name=namepost)
paginator = Paginator(queryset, 20)
return json.dumps([item.to_dict() for item in paginator.object_list])

Hope that helps.

On Thursday, 3 October 2013 14:34:18 UTC+1, Hélio Miranda wrote:
>
> Hi guys.
>
> I'm here with a problem that does not quite know how to solve.
> I have this query:
> result = json.dumps([a.get_json() for a in 
> Player.objects.filter(name=namepost)])
>
> But now I want to return the result with paging, and do not really know 
> how to do ... I've been seeing in the documentation to use the Paginator.
>
> But for example when I do this
> p = Paginator(result, 2)
> print p.count
>
> Gives 1609 ... and the result of the query is 3 records.
>
> Someone can help me?
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/ee66f864-30c7-450d-806a-763f12313c89%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


  1   2   3   4   >