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

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


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.


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

2019-04-24 Thread Szabolcs Hodossy
Thanks for the help, I have checked those release notes, but I was not able
to identify the related change (neither subquery nor __in lookup). I wanted
to give you a deeper look into the code, but during that I managed to
isolate the issue. It seems that the '__in' lookups previously accepted
objects and automatically extracted the referenced columns in case of
Foreign Key fields, but that is not valid now. I added `values('id')`
everywhere, and it solved the problem. I am not sure how to feel about this
change, as 'id' is automatically created.

Br,
Szabolcs

On Tue, Apr 23, 2019 at 4:39 PM Simon Charette  wrote:

> I assume you are either using a Subquery annotation that returns
> multiple results or an __in lookup against a query with multiple columns.
>
> I vaguely remember something changed in this area but it was documented
> in one of the 2.0, 2.1 or 2.2 release notes.
>
> Best,
> Simon
>
> Le mardi 23 avril 2019 10:31:43 UTC-4, hodossy...@gmail.com a écrit :
>>
>> Hello,
>>
>> I am facing the following issue after upgrading to 2.2 from 1.11. Here is
>> the stack trace:
>>
>> Traceback (most recent call last):
>>   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)
>> sqlite3.OperationalError: only a single result allowed for a SELECT that
>> is part of an expression
>>
>> The above exception was the direct cause of the following exception:
>>
>> Traceback (most recent call last):
>>   File "(...)\dashboard\deployment\tests\test_view.py", line 53, in
>> test_display_list_view
>> response = self.client.get(self.url_my_list)
>>   File "(...)\.env\lib\site-packages\django\test\client.py", line 535, in
>> get
>> response = super().get(path, data=data, secure=secure, **extra)
>>   File "(...)\.env\lib\site-packages\django\test\client.py", line 347, in
>> get
>> **extra,
>>   File "(...)\.env\lib\site-packages\django\test\client.py", line 422, in
>> generic
>> return self.request(**r)
>>   File "(...)\.env\lib\site-packages\django\test\client.py", line 503, in
>> request
>> raise exc_value
>>   File "(...)\.env\lib\site-packages\django\core\handlers\exception.py",
>> line 34, in inner
>> response = get_response(request)
>>   File "(...)\.env\lib\site-packages\django\core\handlers\base.py", line
>> 115, in _get_response
>> response = self.process_exception_by_middleware(e, request)
>>   File "(...)\.env\lib\site-packages\django\core\handlers\base.py", line
>> 113, in _get_response
>> response = wrapped_callback(request, *callback_args,
>> **callback_kwargs)
>>   File "(...)\.env\lib\site-packages\django\views\generic\base.py", line
>> 71, in view
>> return self.dispatch(request, *args, **kwargs)
>>   File "(...)\.env\lib\site-packages\django\contrib\auth\mixins.py", line
>> 52, in dispatch
>> return super().dispatch(request, *args, **kwargs)
>>   File "(...)\.env\lib\site-packages\django\views\generic\base.py", line
>> 97, in dispatch
>> return handler(request, *args, **kwargs)
>>   File "(...)\.env\lib\site-packages\django\views\generic\list.py", line
>> 157, in get
>> context = self.get_context_data()
>>   File "(...)\dashboard\deployment\views.py", line 53, in get_context_data
>> context = super().get_context_data(**kwargs)
>>   File "(...)\.env\lib\site-packages\django\views\generic\list.py", line
>> 119, in get_context_data
>> paginator, page, queryset, is_paginated =
>> self.paginate_queryset(queryset, page_size)
>>   File "(...)\.env\lib\site-packages\django\views\generic\list.py", line
>> 69, in paginate_queryset
>> page = paginator.page(page_number)
>>   File "(...)\.env\lib\site-packages\django\core\paginator.py", line 70,
>> in page
>> number = self.validate_number(number)
>>   File "(...)\.env\lib\site-packages\django\core\paginator.py", line 48,
>> in validate_number
>> if number > self.num_pages:
>>   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 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\li

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

2019-04-23 Thread Simon Charette
I assume you are either using a Subquery annotation that returns
multiple results or an __in lookup against a query with multiple columns.

I vaguely remember something changed in this area but it was documented
in one of the 2.0, 2.1 or 2.2 release notes.

Best,
Simon

Le mardi 23 avril 2019 10:31:43 UTC-4, hodossy...@gmail.com a écrit :
>
> Hello,
>
> I am facing the following issue after upgrading to 2.2 from 1.11. Here is 
> the stack trace:
>
> Traceback (most recent call last):
>   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)
> sqlite3.OperationalError: only a single result allowed for a SELECT that 
> is part of an expression
>
> The above exception was the direct cause of the following exception:
>
> Traceback (most recent call last):
>   File "(...)\dashboard\deployment\tests\test_view.py", line 53, in 
> test_display_list_view
> response = self.client.get(self.url_my_list)
>   File "(...)\.env\lib\site-packages\django\test\client.py", line 535, in 
> get
> response = super().get(path, data=data, secure=secure, **extra)
>   File "(...)\.env\lib\site-packages\django\test\client.py", line 347, in 
> get
> **extra,
>   File "(...)\.env\lib\site-packages\django\test\client.py", line 422, in 
> generic
> return self.request(**r)
>   File "(...)\.env\lib\site-packages\django\test\client.py", line 503, in 
> request
> raise exc_value
>   File "(...)\.env\lib\site-packages\django\core\handlers\exception.py", 
> line 34, in inner
> response = get_response(request)
>   File "(...)\.env\lib\site-packages\django\core\handlers\base.py", line 
> 115, in _get_response
> response = self.process_exception_by_middleware(e, request)
>   File "(...)\.env\lib\site-packages\django\core\handlers\base.py", line 
> 113, in _get_response
> response = wrapped_callback(request, *callback_args, **callback_kwargs)
>   File "(...)\.env\lib\site-packages\django\views\generic\base.py", line 
> 71, in view
> return self.dispatch(request, *args, **kwargs)
>   File "(...)\.env\lib\site-packages\django\contrib\auth\mixins.py", line 
> 52, in dispatch
> return super().dispatch(request, *args, **kwargs)
>   File "(...)\.env\lib\site-packages\django\views\generic\base.py", line 
> 97, in dispatch
> return handler(request, *args, **kwargs)
>   File "(...)\.env\lib\site-packages\django\views\generic\list.py", line 
> 157, in get
> context = self.get_context_data()
>   File "(...)\dashboard\deployment\views.py", line 53, in get_context_data
> context = super().get_context_data(**kwargs)
>   File "(...)\.env\lib\site-packages\django\views\generic\list.py", line 
> 119, in get_context_data
> paginator, page, queryset, is_paginated = 
> self.paginate_queryset(queryset, page_size)
>   File "(...)\.env\lib\site-packages\django\views\generic\list.py", line 
> 69, in paginate_queryset
> page = paginator.page(page_number)
>   File "(...)\.env\lib\site-packages\django\core\paginator.py", line 70, 
> in page
> number = self.validate_number(number)
>   File "(...)\.env\lib\site-packages\django\core\paginator.py", line 48, 
> in validate_number
> if number > self.num_pages:
>   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 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
> ret

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
> 
> .
> 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/CAEUEpOTUP_-rdoY8p4%2BfT4%2BTEmCLoSFyLQ1L%3DsdhfPkeHtY3rw%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/CALr9hQ2Wvq0woYMTtze_erq65trSxVi-76FXR0HvmHVoCPNZxw%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 user

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

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
 
 .
 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/CAEUEpOTUP_-rdoY8p4%2BfT4%2BTEmCLoSFyLQ1L%3DsdhfPkeHtY3rw%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/CALr9hQ2Wvq0woYMTtze_erq65trSxVi-76FXR0HvmHVoCPNZxw%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 disc

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 https://gro

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
>>> 
>>> .
>>> 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/CAEUEpOTUP_-rdoY8p4%2BfT4%2BTEmCLoSFyLQ1L%3DsdhfPkeHtY3rw%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/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
>> 
>> .
>> 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/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
>>> 
>>> .
>>> 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.


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


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


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.


Re: Pagination with file upload (MultiValueDictKeyError)

2013-04-15 Thread Venkatraman S
On Tue, Apr 16, 2013 at 10:40 AM,  wrote:

> I have a simple form that takes a user upload, queries a database, and
> displays results in a table.  I receive the following error whenever I try
> to go to the second, third, fourth, etc page:


Why are you querying the DB? You mean, once the file uploads, you want to
requery the DB and get the 'new' list with this list of files?

Btw, I have tried my hands on with django-jquery-file-upload and i think
its one of the better solutions:
https://github.com/sigurdga/django-jquery-file-upload

Venkat
https://twitter.com/venkasub

-- 
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?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.




Re: Pagination in ListView

2012-01-04 Thread J. Cliff Dyer
I've certainly seen blogs where I wished I could paginate negatively,
where -1 would be the last page, -2 the second to last and so on. I was
trying to work my way through a blog's archives from the beginning, but
they kept adding new posts, so I never knew if the page I left off on
was the page I'd have to pick up from.  So to that effect you could make
negative pagination work something like negative indexing in python.

Cheers,
Cliff


On Wed, 2012-01-04 at 15:03 -0500, Dennis Lee Bieber wrote:
> On Wed, 4 Jan 2012 17:23:12 +, Tom Evans 
> wrote:
> 
> >On Wed, Jan 4, 2012 at 12:09 PM, Matt Stevens  wrote:
> >> I've found a solution, but I don't like it.
> >
> >The canonical solution is included in the docs:
> >
> >https://docs.djangoproject.com/en/1.3/topics/pagination/#using-paginator-in-a-view
> >
> >Briefly:
> >
> >
> >  paginator = Paginator(objects, 50, orphans=10)
> >
> >  # Make sure page request is an int. If not, deliver first page.
> >  try:
> >page = int(request.GET.get('page', '1'))
> >  except ValueError:
> >page = 1
> >
> >  # If page request () is out of range, deliver last page of results.
> >  try:
> >objects = paginator.page(page)
> >  except (EmptyPage, InvalidPage):
> >objects = paginator.page(paginator.num_pages)
> >
>   Seems one could have checked the limit first -- though perhaps the
> extra calls would have too much effect on timing...
> 
>   ...
>   page = min( int(request.GET.get("page", "1")),
>   paginator.num_pages)
>   ...
> 
>   Though that leads to the thought (I'm not experienced with the
> system, here more as a learning by osmosis experience), could the
> request ever have a NEGATIVE page number?
> -- 
>   Wulfraed Dennis Lee Bieber AF6VN
> wlfr...@ix.netcom.comHTTP://wlfraed.home.netcom.com/
> 


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination in ListView

2012-01-04 Thread Tom Evans
On Wed, Jan 4, 2012 at 12:09 PM, Matt Stevens  wrote:
> I've found a solution, but I don't like it.

The canonical solution is included in the docs:

https://docs.djangoproject.com/en/1.3/topics/pagination/#using-paginator-in-a-view

Briefly:


  paginator = Paginator(objects, 50, orphans=10)

  # Make sure page request is an int. If not, deliver first page.
  try:
page = int(request.GET.get('page', '1'))
  except ValueError:
page = 1

  # If page request () is out of range, deliver last page of results.
  try:
objects = paginator.page(page)
  except (EmptyPage, InvalidPage):
objects = paginator.page(paginator.num_pages)

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination in ListView

2012-01-04 Thread Matt Stevens
I've found a solution, but I don't like it.
This will show the last page, but - it doesn't do a redirect.

===
class MyListView(ListView):     model = models.Post     template_name
= 'post_list.html'     paginate_by = 10         def
paginate_queryset(self, queryset, page_size):        paginator =
self.get_paginator(queryset, page_size,
allow_empty_first_page=self.get_allow_empty())        page =
self.kwargs.get('page') or self.request.GET.get('page') or 1
        try:            page_number = int(page)        except
ValueError:            if page == 'last':                pasge_number
= paginator.num_pages            else:                raise
Http404(_(u"Page is not 'last', nor can it be converted to an int.")) 
      try:            page = paginator.page(page_number)           
return (paginator, page, page.object_list, page.has_other_pages())   
    except InvalidPage:            page =
paginator.page(paginator.num_pages)            return (paginator,
page, page.object_list,
page.has_other_pages())===


On Jan 4, 11:25 am, Matt Stevens  wrote:
> Hi,
> I'm using a list view to show a list of my objects.
>
> ===
> class MyListView(ListView):
>     model = models.Post
>     template_name = 'post_list.html'
>     paginate_by = 10
> ===
>
> When a visitors goes to a page higher than exists, I'd like it to go
> to the last page. (ie: ?page= goes to ?page=5 if there are only 5
> pages).
> Is 'get_queryset' the right place to do this or am I completely off?
>
> Thank you.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of more than one field

2011-09-07 Thread OC
works as a charm
thanks

On 7 ספטמבר, 17:05, Malcolm Box  wrote:
> On 7 September 2011 14:57, OC  wrote:
>
>
>
>
>
> > Thank you very much for your reply,
> > I changed it but I guess Im doing something wrong cause it still
> > doesnt work:
> > It tries to go to the right page now, but provides nothing although I
> > know there's more than one page:
>
> > in views.py
> > movies_page= int(request.GET.get('page','1'))
> >    try:
> >        moviesp = movpaginator.page(movies_page)...
>
> > in the template:
> >       {% if actors.has_previous %}
> >                                 > src="{{ MEDIA_URL }} images/preview.png">
> >                        {% else %}
>
> > You're setting the movies_page request parameter in the URL you're
>
> generating, but you're reading the *page* request parameter in the view
> function.
>
> Change to "movies_page = int(request.GET.get('movies_page', 1))" and it
> should work-הסתר טקסט מצוטט-
>
> -הראה טקסט מצוטט-

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of more than one field

2011-09-07 Thread Malcolm Box
On 7 September 2011 14:57, OC  wrote:

> Thank you very much for your reply,
> I changed it but I guess Im doing something wrong cause it still
> doesnt work:
> It tries to go to the right page now, but provides nothing although I
> know there's more than one page:
>
> in views.py
> movies_page= int(request.GET.get('page','1'))
>try:
>moviesp = movpaginator.page(movies_page)...
>
> in the template:
>   {% if actors.has_previous %}
> src="{{ MEDIA_URL }} images/preview.png">
>{% else %}
>
>
> You're setting the movies_page request parameter in the URL you're
generating, but you're reading the *page* request parameter in the view
function.

Change to "movies_page = int(request.GET.get('movies_page', 1))" and it
should work

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of more than one field

2011-09-07 Thread OC
Thank you very much for your reply,
I changed it but I guess Im doing something wrong cause it still
doesnt work:
It tries to go to the right page now, but provides nothing although I
know there's more than one page:

in views.py
movies_page= int(request.GET.get('page','1'))
try:
moviesp = movpaginator.page(movies_page)...

in the template:
  {% if actors.has_previous %}

{% else %}


On 7 ספטמבר, 15:53, Malcolm Box  wrote:
> On 7 September 2011 08:25, OC  wrote:
>
>
>
>
>
> > also attaching relevant parts of view.py:
>
> >  movpagin = Paginator(movies, 12)
>
> >    page = int(request.GET.get('page','1'))
> >    try:
> >        moviesp = movpagin.page(page)
> >    except PageNotAnInteger:
> >        # If page is not an integer, deliver first page.
> >        moviesp = movpagin.page(1)
> >    except EmptyPage:
> >        # If page is out of range (e.g. ), deliver last page of
> > results.
> >        moviesp = movpagin.page(movpagin.num_pages)
>
> >    actpagin = Paginator(actors, 8)
>
> >    page = int(request.GET.get('page','1'))
>
> There's the problem right there. You're using the same page variable for
> both sides, so inevitably you'll find they move together.
>
> Put the movies page into a variable called movie_page, and the actors into
> actor_page. Update your links in the template to use the right query for the
> prev/next and all should work fine.
>
> Malcolm-הסתר טקסט מצוטט-
>
> -הראה טקסט מצוטט-

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of more than one field

2011-09-07 Thread Malcolm Box
On 7 September 2011 08:25, OC  wrote:

> also attaching relevant parts of view.py:
>
>
>  movpagin = Paginator(movies, 12)
>
>page = int(request.GET.get('page','1'))
>try:
>moviesp = movpagin.page(page)
>except PageNotAnInteger:
># If page is not an integer, deliver first page.
>moviesp = movpagin.page(1)
>except EmptyPage:
># If page is out of range (e.g. ), deliver last page of
> results.
>moviesp = movpagin.page(movpagin.num_pages)
>
>actpagin = Paginator(actors, 8)
>
>page = int(request.GET.get('page','1'))
>

There's the problem right there. You're using the same page variable for
both sides, so inevitably you'll find they move together.

Put the movies page into a variable called movie_page, and the actors into
actor_page. Update your links in the template to use the right query for the
prev/next and all should work fine.

Malcolm

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of more than one field

2011-09-07 Thread bruno desthuilliers
On Sep 6, 4:41 pm, Yaşar Arabacı  wrote:
> I think your question can be solved with javascript and ajax, rather than
> with django. How is your knowledge in that area?


This can definitly be resolved with Django, and it's always better to
have something working without js / ajax when possible (you can then
add js / ajax afterward).

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of more than one field

2011-09-07 Thread OC
also attaching relevant parts of view.py:


  movpagin = Paginator(movies, 12)

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

actpagin = Paginator(actors, 8)

page = int(request.GET.get('page','1'))
try:
actp = actpagin.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
actp = actpagin.page(1)
except EmptyPage:
# If page is out of range (e.g. ), deliver last page of
results.
actp = actpagin.page(actpagin.num_pages)
cntx = RequestContext(request,{
'actors':actp,
'movies' : moviesp,
})
return render_to_response('display.html',cntx)


On 7 ספטמבר, 08:54, OC  wrote:
> I am familiar with js but not with ajax
> I thought that django supports these kind of matters ... isnt it
> trivial?
>
> Attached the code
> Please advise
>
> {% for movie in movies.object_list %#}
>                 
>                                         "whitestripe" "bluestripe" %}>{{movie.name}} 
>                   
>
>                 {% endfor %}
>
>                 
>                         
>                         {% if movies.has_previous %}
>                                 
>                         {% else %}
>                                 
>                         {% endif %}
>
>                         
>                         {% for page_number in
> movies.paginator.page_range %}
>                                 {% if page_number == movies.number %}
>                                          class="pagination_current">{{ movies.number }}
>                                 {% else %}
>                                         {{ page_number }}
>                                 {% endif %}
>                         {% endfor %}
>
>                       
>                         {% if movies.has_next %}
>                                 
>                         {% else %}
>                                 
>                         {% endif %}
>                 
>         
>
>             {% for actor in actors.object_list %}
>                         {% load parseval %}
>                                 {% autoescape off %}
>                         
>                                 
>                                          id="box_header">{{ actor.pt|upper }}
>                                 
>                         
>                                 {% endautoescape %}
>                 {% empty %}
>                 {% endfor %}
>          
>                         
>                         {% if actors.has_previous %}
>                                 
>                         {% else %}
>                                 
>                         
>                         {% for page_number in
> actors.paginator.page_range %}
>                                 {% if page_number == actors.number %}
>                                          class="pagination_current">{{ actors.number }}
>                                 {% else %}
>                                         {{ page_number }}
>                                 {% endif %}
>                         {% endfor %}
>                         
>                         {% if actors.has_next %}
>                                 
>                         {% else %}
>                                 
>                         {% endif %}
>                 
>
> On 6 ספטמבר, 17:41, Yaşar Arabacı  wrote:
>
>
>
> > I think your question can be solved with javascript and ajax, ratherthan
> > with django. How is your knowledge in that area?
>
> > 2011/9/6 OC 
>
> > > Hi,
>
> > > I am new to django and I have apaginationquestion:
> > > In my web page I need to display 2 query results of two different
> > > tables
> > > Each result is displayed in a different div in the same page.
>
> > > How can I implement "multiple"paginationmeaning that each result is
> > > displayed in its own panel and has its own previous and next buttons
> > > but doesn't affect the other's query result?
>
> > > For instance - I have a panel of movies, display 10 each time, and
> > > have a prev and next buttons dedicated to the movies only
> > > Plus
> > > In the same page, I have a panel of actors, display 10 each time, and
> > > have a prev and next buttons dedicated to the actors only
>
> > > My current (wrong) implementation is
> > > usepaginationfor the both of them but when pressing the next/
> > > previous button ofone- it affects (as expected) the display of the
> > > otheronebecause the entire page has changed.
>
> > > Thanks in advance,
> > > Osnat
>
> > > --
> > > You received this message because you are subscribed to the Google Groups

Re: Pagination of more than one field

2011-09-06 Thread OC
I am familiar with js but not with ajax
I thought that django supports these kind of matters ... isnt it
trivial?

Attached the code
Please advise

{% for movie in movies.object_list %#}

   {{movie.name}} 
  

{% endfor %}



{% if movies.has_previous %}

{% else %}

{% endif %}


{% for page_number in
movies.paginator.page_range %}
{% if page_number == movies.number %}
{{ movies.number }}
{% else %}
{{ page_number }}
{% endif %}
{% endfor %}

  
{% if movies.has_next %}

{% else %}

{% endif %}



{% for actor in actors.object_list %}
{% load parseval %}
{% autoescape off %}


{{ actor.pt|upper }}


{% endautoescape %}
{% empty %}
{% endfor %}
 

{% if actors.has_previous %}

{% else %}


{% for page_number in
actors.paginator.page_range %}
{% if page_number == actors.number %}
{{ actors.number }}
{% else %}
{{ page_number }}
{% endif %}
{% endfor %}

{% if actors.has_next %}

{% else %}

{% endif %}



On 6 ספטמבר, 17:41, Yaşar Arabacı  wrote:
> I think your question can be solved with javascript and ajax, rather than
> with django. How is your knowledge in that area?
>
> 2011/9/6 OC 
>
>
>
>
>
> > Hi,
>
> > I am new to django and I have a pagination question:
> > In my web page I need to display 2 query results of two different
> > tables
> > Each result is displayed in a different div in the same page.
>
> > How can I implement "multiple" pagination meaning that each result is
> > displayed in its own panel and has its own previous and next buttons
> > but doesn't affect the other's query result?
>
> > For instance - I have a panel of movies, display 10 each time, and
> > have a prev and next buttons dedicated to the movies only
> > Plus
> > In the same page, I have a panel of actors, display 10 each time, and
> > have a prev and next buttons dedicated to the actors only
>
> > My current (wrong) implementation is
> > use pagination for the both of them but when pressing the next/
> > previous button of one - it affects (as expected) the display of the
> > other one because the entire page has changed.
>
> > Thanks in advance,
> > Osnat
>
> > --
> > You received this message because you are subscribed to the Google Groups
> > "Django users" group.
> > To post to this group, send email to django-users@googlegroups.com.
> > To unsubscribe from this group, send email to
> > django-users+unsubscr...@googlegroups.com.
> > For more options, visit this group at
> >http://groups.google.com/group/django-users?hl=en.
>
> --http://yasar.serveblog.net/-הסתר טקסט מצוטט-
>
> -הראה טקסט מצוטט-

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of more than one field

2011-09-06 Thread Yaşar Arabacı
I think your question can be solved with javascript and ajax, rather than
with django. How is your knowledge in that area?

2011/9/6 OC 

> Hi,
>
> I am new to django and I have a pagination question:
> In my web page I need to display 2 query results of two different
> tables
> Each result is displayed in a different div in the same page.
>
> How can I implement "multiple" pagination meaning that each result is
> displayed in its own panel and has its own previous and next buttons
> but doesn't affect the other's query result?
>
> For instance - I have a panel of movies, display 10 each time, and
> have a prev and next buttons dedicated to the movies only
> Plus
> In the same page, I have a panel of actors, display 10 each time, and
> have a prev and next buttons dedicated to the actors only
>
> My current (wrong) implementation is
> use pagination for the both of them but when pressing the next/
> previous button of one - it affects (as expected) the display of the
> other one because the entire page has changed.
>
> Thanks in advance,
> Osnat
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to django-users@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users+unsubscr...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
>
>


-- 
http://yasar.serveblog.net/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: pagination peculiarities...

2011-04-15 Thread Karen Tracey
On Fri, Apr 15, 2011 at 2:44 PM, Markus T. wrote:

>
> I have a strange effect using pagination.
>
> I have a model with events that have a date, time, title, description
> field and so on. I display the events using pagination. In the model's
> Meta class I tell Django to order by date.
>
> I create a queryset like this:
>
> events = Event.objects.filter(date__gte=date.today())
>
> All events are there in the result. But after I apply pagination, one
> event is missing, and another event of the same date comes twice. If I
> raise the items_per_page parameter so I get only one page, all events
> are there as well.
>
> If I tell Django to order [by date, time, title], all events are
> there, using pagination or not.
>
> Can anyone explain this?


If you don't supply a total ordering, which you don't if you only specify
order by date and there are multiple events on the same date, then the
database is free to choose whatever ordering it likes for the elements not
covered by the specified ordering. It is also free to choose different
orderings for these not- fully-ordered items each time you ask it for a
portion of the overall set. Postgres in particular is prone to actually
doing this; multiple "identical" queries with the same limit/offset values
will often return different results.

Karen
-- 
http://tracey.org/kmt/

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination of Search Results - URL issue

2011-03-21 Thread Daniel Roseman


On Monday, March 21, 2011 4:49:34 AM UTC, Andrew Godfrey wrote:
>
> Hi, 
>
> I am paginating the output of a query. Everything works fine and the 
> first page of results is displayed. The problem is that the url to 
> access pages 2 (http://127.0.0.1:8000/search/?page=2) and following 
> fall back to the search form and do not display the second page of 
> results. 
>

Yes, because you are using POST for the search query, and subsequent 
requests are GETs.

So, don't do that. Search forms are a case where GET is the right method to 
use: they don't update anything on the server, they simply request 
information. You should include the search query on every pagination link.
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination with bound form

2010-10-15 Thread Devin M
Wait looks like i made an error.
http://testsite.com/page/{%pk - 1%}>Previous Page
and you might not be able to use pk so see if you can use data.pk
let me know if it works.

Regards,
Devin M
On Oct 15, 6:56 am, Devin M  wrote:
> Oh you want just one record per page? Thats easy.
> urls.py
> (r'^page/(?P\d+)/$', 'data.views.pagelisting'),
>
> views.py
> def pagelisting(request, page_number):
>     data_list = Data.objects.filter(pk=page_number)
>     return render_to_response('list.html', {"data_list": data_list})
>
> template list.html
> {% if datalist %}
>     
>     {% for data in  datalist %}
>         {{ data.text }}
>     {% endfor %}
>     
> http://testsite.com/page/{%pk - 1%}>Next Page
> {% else %}
>     No data is available.
> {% endif %}
>
> On Oct 15, 6:43 am, David  wrote:
>
> > Hi Devin
>
> > Thank you for your reply.
>
> > I'm not sure if I've explained myself properly, or if I'm
> > misinterpreting your reply. What I am aiming for is a form containing
> > a single record. At the bottom of this form will be the pagination
> > tools << Prev 1 2 3 etc. which will enable the user to navigate
> > through the records individually in my form. I was hoping that the
> > pagination had the ability to know the current records primary key so
> > that I could render the form with a simple Data.objects.get(pk=1) this
> > would then achieve the desired effect (I think).

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination with bound form

2010-10-15 Thread Devin M
Oh you want just one record per page? Thats easy.
urls.py
(r'^page/(?P\d+)/$', 'data.views.pagelisting'),

views.py
def pagelisting(request, page_number):
data_list = Data.objects.filter(pk=page_number)
return render_to_response('list.html', {"data_list": data_list})

template list.html
{% if datalist %}

{% for data in  datalist %}
{{ data.text }}
{% endfor %}

http://testsite.com/page/{%pk - 1%}>Next Page
{% else %}
No data is available.
{% endif %}

On Oct 15, 6:43 am, David  wrote:
> Hi Devin
>
> Thank you for your reply.
>
> I'm not sure if I've explained myself properly, or if I'm
> misinterpreting your reply. What I am aiming for is a form containing
> a single record. At the bottom of this form will be the pagination
> tools << Prev 1 2 3 etc. which will enable the user to navigate
> through the records individually in my form. I was hoping that the
> pagination had the ability to know the current records primary key so
> that I could render the form with a simple Data.objects.get(pk=1) this
> would then achieve the desired effect (I think).

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination with bound form

2010-10-15 Thread David
Hi Devin

Thank you for your reply.

I'm not sure if I've explained myself properly, or if I'm
misinterpreting your reply. What I am aiming for is a form containing
a single record. At the bottom of this form will be the pagination
tools << Prev 1 2 3 etc. which will enable the user to navigate
through the records individually in my form. I was hoping that the
pagination had the ability to know the current records primary key so
that I could render the form with a simple Data.objects.get(pk=1) this
would then achieve the desired effect (I think).

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination with bound form

2010-10-15 Thread Devin M
So you have a page number thats getting passed from a url, right? and
then you want to display records based on that page number? you could
do something like this:
urls.py
(r'^page/(?P\d+)/$', 'data.views.pagelisting'),

views.py
def pagelisting(request, page_number):
records = range(page_number + 10)
data_list = Data.objects.filter(pk=records)
return render_to_response('list.html', {"formset": formset})

template list.html
{% if formset %}

{% for data in formset %}
{{ data.text }}
{% endfor %}

{% else %}
No data is available.
{% endif %}

Might not be 100 percent on the code but i hope it helps.

Regards,
Devin Morin


I think this would work because you can see them using an array in
http://docs.djangoproject.com/en/dev/topics/db/queries/#the-pk-lookup-shortcut

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.



Re: Pagination in the admin , where is?

2009-08-06 Thread Asinox

oh man :) thanks :) so easy :)

On Aug 6, 10:55 pm, "Adam V."  wrote:
> ModelAdmin.list_per_page will let you control how many items appear on
> a particular admin 
> list:http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contri...
>
> On Aug 6, 7:50 pm, Asinox  wrote:
>
>
>
> > Well, i cant find any about it, i want to know if the pagination exist
> > in the admin... i think that "yes"..but .. i cant see any thing
> > about..
>
> > thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination in the admin , where is?

2009-08-06 Thread Adam V.

ModelAdmin.list_per_page will let you control how many items appear on
a particular admin list:
http://docs.djangoproject.com/en/dev/ref/contrib/admin/#django.contrib.admin.ModelAdmin.list_per_page

On Aug 6, 7:50 pm, Asinox  wrote:
> Well, i cant find any about it, i want to know if the pagination exist
> in the admin... i think that "yes"..but .. i cant see any thing
> about..
>
> thanks
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination

2009-03-30 Thread Bartek SQ9MEV

Konstantin S pisze:
> Hello!
> second one I found at code.google.com. (Url is
> http://code.google.com/p/django-pagination/). Which one would you
> recommend ?

This one works well for me (it uses the built-one), but remember not to
use {% if object_list %} before pagination tags in your template - the
"if" tag evaluates the queryset, that was cause of big overhead in one
of my apps..

Discussion few months ago:
http://www.tinyurl.pl?Q4IaEv3v

-- 
jid: b.rad...@chrome.pl



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination

2009-03-30 Thread Benjamin Buch

django-pagination makes use of the Djangos' built in pagination,
so it's more like a wrapper on top but no distinct 'engine'.

If you have a need for some special customized pagination,
I would recommend Djangos' own pagination,
but if you want easy setup and some more generic pagination funcionality
I would use django-pagination.

As Jakob mentioned,
it's really easy and well written and should cover most use cases.

Benjamin

Am 30.03.2009 um 12:36 schrieb Konstantin S:

> Hello!
>
> I noticed that there are two paginations 'engines' available for
> django. The first one is in django distribution itself
> (http://docs.djangoproject.com/en/1.0/topics/pagination/), and the
> second one I found at code.google.com. (Url is
> http://code.google.com/p/django-pagination/). Which one would you
> recommend ?


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination

2009-03-30 Thread Briel

Hi
I haven't actually used django's own pagination, so I guess I can't
really compare. Though working with django-pagination is really
easy and it's well written. Made by the people that made pinax...

~Jakob

On 30 Mar., 12:36, Konstantin S  wrote:
> Hello!
>
> I noticed that there are two paginations 'engines' available for
> django. The first one is in django distribution itself
> (http://docs.djangoproject.com/en/1.0/topics/pagination/), and the
> second one I found at code.google.com. (Url 
> ishttp://code.google.com/p/django-pagination/). Which one would you
> recommend ?
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination django

2009-03-25 Thread Joe

nicemira wrote:
> please friends,
> how can I paginate my product with this method: I want to do a newline
> after every two products

Doing a newline after every two products is not pagination. Here is an 
example that adds a horizontal rule after every two products:

{% for product in products %}
 {% if forloop.counter|divisibleby:"2" %}
 {{ product }}
 
 {% else %}
 {{ product }}
 {% endif %}
{% endfor %}

See the documentation at:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#divisibleby

If you mean you want a page for every two products, see the 
documentation at:

http://docs.djangoproject.com/en/dev/topics/pagination/

Please try to be more specific and informative in your questions, it 
will help you get better answers.

- Joe



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination django

2009-03-25 Thread Justin Lilly

I believe you're looking for the {% cycle %} template tag, which you
can find more information about here:

http://docs.djangoproject.com/en/dev/ref/templates/builtins/#cycle

{% cycle '' '' %}

 -justin

On Wed, Mar 25, 2009 at 6:15 AM, nicemira  wrote:
>
> please friends,
> how can I paginate my product with this method: I want to do a newline
> after every two products
> please,answer me as soon as possible
>
> >
>



-- 
Justin Lilly
Python/Django Developer
http://justinlilly.com

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination problem with "Next" and saving results as a dictionary

2009-03-16 Thread Jesse

Hello Paul,

Thanks!! I'll try it.

On Mar 13, 2:21 pm, pkenjora  wrote:
> Uhm maybe this post will help its a tag that handles thepaginationon 
> query objects.  I've used it in a few of my projects and
> its quite handy.
>
> http://blog.awarelabs.com/?p=29
>
> -Paul
>
> On Mar 13, 12:13 pm, Jesse  wrote:
>
> > Hello Micah,
>
> > I can get the q with GET, but I have too complicated of a search and I
> > need to use POST.  I'm having much difficulty with my template code
> > with POST to work with paginator.  I'll keep trying.  Thanks for your
> > patience and help.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination problem with "Next" and saving results as a dictionary

2009-03-13 Thread pkenjora

Uhm maybe this post will help its a tag that handles the
pagination on query objects.  I've used it in a few of my projects and
its quite handy.

http://blog.awarelabs.com/?p=29

-Paul

On Mar 13, 12:13 pm, Jesse  wrote:
> Hello Micah,
>
> I can get the q with GET, but I have too complicated of a search and I
> need to use POST.  I'm having much difficulty with my template code
> with POST to work with paginator.  I'll keep trying.  Thanks for your
> patience and help.
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination problem with "Next" and saving results as a dictionary

2009-03-13 Thread Jesse

Hello Micah,

I can get the q with GET, but I have too complicated of a search and I
need to use POST.  I'm having much difficulty with my template code
with POST to work with paginator.  I'll keep trying.  Thanks for your
patience and help.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination problem with "Next" and saving results as a dictionary

2009-03-12 Thread Micah Ransdell
Jesse,

You need to change your code in the view to look at the GET parameter rather
than POST. Change this line:

query = request.POST['q']

to:

query = request.GET['q']

Also, make sure when you are submitting to your search page that you are
submitting the page with GET in the method of your form. Your second method
of checking if query is valid then inserting it into the href looks fine,
you just need to change which method you are accessing it in your view.

Micah

On Thu, Mar 12, 2009 at 1:16 PM, Jesse  wrote:

>
> Hello Micah,
>
> I tried this in the template:
> next
>
> The browser URL is:
> http://127.0.0.1:8000/Search/?q=?&page=2
>
> and this in the template:
>
>  next
>
> The browser URL is:
> http://127.0.0.1:8000/Search/?q=harris&page=2,
>
> which is correct for q, but the error for both is still:
>
> Request Method: GET
> Request URL:http://127.0.0.1:8000/Search/
> Exception Type: MultiValueDictKeyError
> Exception Value:
>
> Key 'q' not found in 
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination problem with "Next" and saving results as a dictionary

2009-03-12 Thread Jesse

Hello Micah,

I tried this in the template:
next

The browser URL is:
http://127.0.0.1:8000/Search/?q=?&page=2

and this in the template:

 next

The browser URL is:
http://127.0.0.1:8000/Search/?q=harris&page=2,

which is correct for q, but the error for both is still:

Request Method: GET
Request URL:http://127.0.0.1:8000/Search/
Exception Type: MultiValueDictKeyError
Exception Value:

Key 'q' not found in 
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination problem with "Next" and saving results as a dictionary

2009-03-12 Thread Jesse

Hello Micah,

My view is too commplicated.  The q and the pathologyid ( I actually
have two other retrievals that also appended with these) are all
appended into the "list".  What I need to figure out is how to send
the "list" to it's own dictionary, which I can then retrieve with a
new view and use that view for the pagination.  I can see that the
pagination works better with a simple retrieval.  Can you tell me how
to create a new object from "list" that can be retrieved in a new
view?

Thanks.

On Mar 11, 10:20 pm, Micah Ransdell  wrote:
> Jesse,
>
> The error you are getting is from "q" not being in your post
> QueryDictionary. This happens because when you click next you are not
> rePOSTing the q variable. Either you can put the q variable into an input
> box and POST it again by making your next link a submit button, or you could
> change q to a querystring parameter and use request.GET to retrieve it. This
> makes it easier to pass on to future pages in your search by putting it into
> the querystring for your next link as well.
>
> I have solved this by putting another variable in my next link like this:
>
> {% if page_obj.has_next %}
>     next
> {% endif %}
>
> Micah
>
> On Wed, Mar 11, 2009 at 12:51 PM, Jesse  wrote:
>
> > The following code is for a search on q and attaches tuples from the
> > search on another model.  The search results are appended together to
> > create the final data results "list".
>
> > def Bypub(request):
> >   query = request.POST['q']
> >    if query:
> >        qset = (
> >            Q(pubtitlestrip__icontains=query) |
> >        )
> >        pubresults = Publication.objects.filter(qset).distinct()  #
> > original
> >    else:
> >        pubresults = []
> >    pathology_id = request.POST['pathology_id']  #original works
> >    p = get_object_or_404(Pathology, pk=pathology_id)
> >    pub1=Publication.objects.filter(pathpubcombo__pathology=p)
> >    for publication in pubresults:
> >        if publication not in list:
> >            list.append(publication)  # the object going to template
>
> >    paginator = Paginator(list, 5)
> >    try:
> >        page = int(request.GET.get('page', '1'))
> >    except ValueError:
> >        page = 1
> >    try:
> >        publications = paginator.page(page)
> >    except (EmptyPage, InvalidPage):
> >        publications = paginator.page(paginator.num_pages)
> >    return render_to_response('search/searchresults_pub.html', {
> >        "query": query,
> >        "pubresults": pubresults,
> >        'pub1': pub1,
> >        'pathology': p,
> >        'list' : list,
> >        'publications' : publications,
> >    },
> >        context_instance=RequestContext(request)
> >    )
>
> > The template:
>
> > {% for publication in publications.object_list %}
> >    {{ publication.pubtitle|safe }}
> >      {% endfor %}
> >    {% else %}
> >      No publications found.  Please try a different search.
> >    {% endif %}
>
> >  
> >    
> >        {% if publications.has_previous %}
> >            previous
> >        {% endif %}
>
> >        
> >            Page {{ publications.number }} of
> > {{ publications.paginator.num_pages }}.
> >        
>
> >        {% if publications.has_next %}
> >            next > a>
> >        {% endif %}
> >    
> > 
>
> > Every thing works just fine until I select the link for the "Next"
> > page.  The URL in browser is:
> >http://127.0.0.1:8000/Search/?page=2
> > ERROR:
> > Exception Type:         MultiValueDictKeyError
> > Exception Value:
> > Key 'q' not found in 
>
> > I think when I select "Next" it is returning to the def Bypub, but of
> > course the q is not there the second time.  How do I preserver the
> > "list" as a dictionary to output to the next page?  This might also
> > answer the other problem I'm having with sending the "list" to a csv
> > file.  I also need some way to store the data for the csv file.
> > Any help is appreciated.  Thanks.
>
>
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination problem with "Next" and saving results as a dictionary

2009-03-11 Thread Micah Ransdell
Jesse,

The error you are getting is from "q" not being in your post
QueryDictionary. This happens because when you click next you are not
rePOSTing the q variable. Either you can put the q variable into an input
box and POST it again by making your next link a submit button, or you could
change q to a querystring parameter and use request.GET to retrieve it. This
makes it easier to pass on to future pages in your search by putting it into
the querystring for your next link as well.

I have solved this by putting another variable in my next link like this:

{% if page_obj.has_next %}
next
{% endif %}

Micah

On Wed, Mar 11, 2009 at 12:51 PM, Jesse  wrote:

>
> The following code is for a search on q and attaches tuples from the
> search on another model.  The search results are appended together to
> create the final data results "list".
>
> def Bypub(request):
>   query = request.POST['q']
>if query:
>qset = (
>Q(pubtitlestrip__icontains=query) |
>)
>pubresults = Publication.objects.filter(qset).distinct()  #
> original
>else:
>pubresults = []
>pathology_id = request.POST['pathology_id']  #original works
>p = get_object_or_404(Pathology, pk=pathology_id)
>pub1=Publication.objects.filter(pathpubcombo__pathology=p)
>for publication in pubresults:
>if publication not in list:
>list.append(publication)  # the object going to template
>
>paginator = Paginator(list, 5)
>try:
>page = int(request.GET.get('page', '1'))
>except ValueError:
>page = 1
>try:
>publications = paginator.page(page)
>except (EmptyPage, InvalidPage):
>publications = paginator.page(paginator.num_pages)
>return render_to_response('search/searchresults_pub.html', {
>"query": query,
>"pubresults": pubresults,
>'pub1': pub1,
>'pathology': p,
>'list' : list,
>'publications' : publications,
>},
>context_instance=RequestContext(request)
>)
>
> The template:
>
> {% for publication in publications.object_list %}
>{{ publication.pubtitle|safe }}
>  {% endfor %}
>{% else %}
>  No publications found.  Please try a different search.
>{% endif %}
>
>  
>
>{% if publications.has_previous %}
>previous
>{% endif %}
>
>
>Page {{ publications.number }} of
> {{ publications.paginator.num_pages }}.
>
>
>{% if publications.has_next %}
>next a>
>{% endif %}
>
> 
>
> Every thing works just fine until I select the link for the "Next"
> page.  The URL in browser is:
> http://127.0.0.1:8000/Search/?page=2
> ERROR:
> Exception Type: MultiValueDictKeyError
> Exception Value:
> Key 'q' not found in 
>
> I think when I select "Next" it is returning to the def Bypub, but of
> course the q is not there the second time.  How do I preserver the
> "list" as a dictionary to output to the next page?  This might also
> answer the other problem I'm having with sending the "list" to a csv
> file.  I also need some way to store the data for the csv file.
> Any help is appreciated.  Thanks.
>
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination Suggestions

2008-12-26 Thread Dana

I highly recommend:

http://code.google.com/p/django-pagination/

Very easy to implement, requires no modifications to views or models,
purely template based (via template tags).

On Dec 24, 2:36 pm, kev  wrote:
> Ah ok :)
>
> Thx!!
>
> On Dec 24, 5:12 pm, Brian Neal  wrote:
>
> > On Dec 24, 3:54 pm, kev  wrote:
>
> > > Hello,
> > > Im trying to create a digg type pagination. Is there a decent
> > > pagination app already out there that works for 1.0? I tried looking
> > > but havent succeeded.
>
> > > Thanks,
> > > Kev
>
> > I'm using this. Works great!
>
> >http://www.djangosnippets.org/snippets/773/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination Suggestions

2008-12-24 Thread kev

Ah ok :)

Thx!!

On Dec 24, 5:12 pm, Brian Neal  wrote:
> On Dec 24, 3:54 pm, kev  wrote:
>
> > Hello,
> > Im trying to create a digg type pagination. Is there a decent
> > pagination app already out there that works for 1.0? I tried looking
> > but havent succeeded.
>
> > Thanks,
> > Kev
>
> I'm using this. Works great!
>
> http://www.djangosnippets.org/snippets/773/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination Suggestions

2008-12-24 Thread Brian Neal

On Dec 24, 3:54 pm, kev  wrote:
> Hello,
> Im trying to create a digg type pagination. Is there a decent
> pagination app already out there that works for 1.0? I tried looking
> but havent succeeded.
>
> Thanks,
> Kev

I'm using this. Works great!

http://www.djangosnippets.org/snippets/773/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination of non-Django database

2008-11-26 Thread huw_at1

Ahh great - many thanks. I did wonder this but without better
documentation I could not be certain. I currently build a list from my
sql query so this should be no problem.

Much appreciated.

On Nov 26, 12:47 pm, Thomas Kerpe <[EMAIL PROTECTED]> wrote:
> Am 26.11.2008 13:19 Uhr, huw_at1 schrieb:> A small part of my framework 
> queries a non-Django db due to it being a
> > legacy db with primary keys already in use. My question is is there a
> > recognised way of applying pagination to non-Django db objects such
> > that I can paginate the sql select query on this database?
>
> I am not shure I had understand your question correct.
>
> The Django paginator works with lists/tuples, so all you have to do is
> either let your "other DB" act like a list/tuple, or build a small
> wrapper that allows the [from:to] syntax and a count() or __len__() method.
>
> If that don't work you can of course overload the Paginator itself. I
> have done this [1] for CouchDB which has not yet any compatible wrapper
> and uses a completely different approach as it is an document-oriented
> database. My code is more a hack but it works well.
>
> I would recommend to use the first approach if possible.
>
> This is only my opinion and is of course not in any way official.
>
> //Thomas
>
> [1]http://www.djangosnippets.org/snippets/1208/
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination of non-Django database

2008-11-26 Thread Thomas Kerpe

Am 26.11.2008 13:19 Uhr, huw_at1 schrieb:
> A small part of my framework queries a non-Django db due to it being a
> legacy db with primary keys already in use. My question is is there a
> recognised way of applying pagination to non-Django db objects such
> that I can paginate the sql select query on this database?
>
I am not shure I had understand your question correct.

The Django paginator works with lists/tuples, so all you have to do is 
either let your "other DB" act like a list/tuple, or build a small 
wrapper that allows the [from:to] syntax and a count() or __len__() method.

If that don't work you can of course overload the Paginator itself. I 
have done this [1] for CouchDB which has not yet any compatible wrapper 
and uses a completely different approach as it is an document-oriented 
database. My code is more a hack but it works well.

I would recommend to use the first approach if possible.

This is only my opinion and is of course not in any way official.

//Thomas

[1] http://www.djangosnippets.org/snippets/1208/

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination best practices

2008-08-23 Thread Juan Hernandez
Yep, thank you very much

jhv

On Mon, Aug 25, 2008 at 1:09 AM, Karen Tracey <[EMAIL PROTECTED]> wrote:

> On Sun, Aug 24, 2008 at 1:23 AM, Juan Hernandez <[EMAIL PROTECTED]>wrote:
>
>>
>> So, let's say that everytime i get a page, the internat query to the db
>> just gets the, lets say, 10 rows that I requested? because I'm using
>> objects.all(). In that process, where is the DB being hit?
>>
>>
> Model.objects.all() is a QuerySet, which is lazy:
> http://www.djangoproject.com/documentation/db-api/#querysets-are-lazy.
> The Paginator will further limit the QuerySet before doing anything that
> causes the QuerySet to be evaluated (causing a read from the database).  The
> Paginator may call count() on the QuerySet to read the total number of items
> from the DB (I'd have to look at the implementaiton, and it could depend on
> how you use it), but the actual reading of the data from the table won't
> happen until your code calls the paginator to retrieve the data in a page.
>
> Karen
>
> >
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination best practices

2008-08-23 Thread Juan Hernandez
I think I get it...

domains = g.objects.all() just makes the QuerySet and paginator =
ObjectPaginator(domains, 10) executes the query limiting the records to the
one requested...

Excellent

Thanks for your help
jhv

On Mon, Aug 25, 2008 at 12:53 AM, Juan Hernandez <[EMAIL PROTECTED]>wrote:

>
>> Using the Pagniator makes it so that when you hit the DB, the retrieved
>> results are limited to those relevant for the page you are displaying.  You
>> are not reading the whole table and then tossing away everything except what
>> is on the page your are displaying, you are only reading from the DB what is
>> actually going to be displayed on the requested page.  So your hitting the
>> DB for each request is not a problem.  Don't worry about it.
>>
>
> Thanks for your answer
>
> So, let's say that everytime i get a page, the internat query to the db
> just gets the, lets say, 10 rows that I requested? because I'm using
> objects.all(). In that process, where is the DB being hit?
>
> jhv
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination best practices

2008-08-23 Thread Karen Tracey
On Sun, Aug 24, 2008 at 1:23 AM, Juan Hernandez <[EMAIL PROTECTED]>wrote:

>
> So, let's say that everytime i get a page, the internat query to the db
> just gets the, lets say, 10 rows that I requested? because I'm using
> objects.all(). In that process, where is the DB being hit?
>
>
Model.objects.all() is a QuerySet, which is lazy:
http://www.djangoproject.com/documentation/db-api/#querysets-are-lazy.  The
Paginator will further limit the QuerySet before doing anything that causes
the QuerySet to be evaluated (causing a read from the database).  The
Paginator may call count() on the QuerySet to read the total number of items
from the DB (I'd have to look at the implementaiton, and it could depend on
how you use it), but the actual reading of the data from the table won't
happen until your code calls the paginator to retrieve the data in a page.

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination best practices

2008-08-23 Thread Juan Hernandez
>
>
> Using the Pagniator makes it so that when you hit the DB, the retrieved
> results are limited to those relevant for the page you are displaying.  You
> are not reading the whole table and then tossing away everything except what
> is on the page your are displaying, you are only reading from the DB what is
> actually going to be displayed on the requested page.  So your hitting the
> DB for each request is not a problem.  Don't worry about it.
>

Thanks for your answer

So, let's say that everytime i get a page, the internat query to the db just
gets the, lets say, 10 rows that I requested? because I'm using
objects.all(). In that process, where is the DB being hit?

jhv

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination best practices

2008-08-23 Thread Karen Tracey
On Fri, Aug 22, 2008 at 8:05 PM, Juan Hernandez <[EMAIL PROTECTED]>wrote:

> I have this very simple and primitive pagination method being called with
> this instruction in urls.py
>
> [snipped]
> Every time I hit something like domain/pyisp/menu/2 it shows the second
> page of the QuerySet. Everything works great but my question is, if I'm in
> domain/pyisp/menu/2 and then click next to load domain/pyisp/menu/3, would
> these instructions :
>
> domains = g.objects.all()
> paginator = ObjectPaginator(domains, 10)
>
> hit the DB again?? if it does, what would be the best practice in order to
> keep everythong in memory to avoid accessing the database everytime I click
> next or previous??
>

Yes, you're going to hit the DB again each time you retrieve data for a
page.  There's no way to avoid that.  You cannot maintain state across
different requests (well, you can with  caching, but that doesn't apply here
since you are asking about requesting different pages).

Using the Pagniator makes it so that when you hit the DB, the retrieved
results are limited to those relevant for the page you are displaying.  You
are not reading the whole table and then tossing away everything except what
is on the page your are displaying, you are only reading from the DB what is
actually going to be displayed on the requested page.  So your hitting the
DB for each request is not a problem.  Don't worry about it.

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination best practices

2008-08-23 Thread Juan Hernandez
any suggestions?? hehehe

On Sat, Aug 23, 2008 at 7:35 PM, Juan Hernandez <[EMAIL PROTECTED]>wrote:

> I have this very simple and primitive pagination method being called with
> this instruction in urls.py
>
> ###
> (r'^pyisp/menu/(\d+)/$', 'mail.views.menuPaginator'),
> ###
>
> This is the method
>
> ###
> def menuPaginator(request, number):
>
> domains = g.objects.all()
> paginator = ObjectPaginator(domains, 10)
> pages = str(paginator.pages)
> lista = paginator.get_page(number)
>
> #define whether there is a previous or a next page
>
> if paginator.has_next_page(int(number)) == True:
> numberRes = str(int(number) + 1)
> next = " >> "
> else:
> next = '>>'
>
> if paginator.has_previous_page(int(number)) == True:
> numberRes = str(int(number) - 1)
> previous = " << "
> else:
> previous = '<<'
>
> return render_to_response('basic.html',{
> 'titleWeb': 'PyISP Menu',
> 'titleH1': 'Domains',
> 'submitValue': "'Search'",
> 'pages': "Has " + pages + " pages",
> 'lista': lista,
> 'previous': previous,
> 'next': next,
>
> })
> ###
>
> Every time I hit something like domain/pyisp/menu/2 it shows the second
> page of the QuerySet. Everything works great but my question is, if I'm in
> domain/pyisp/menu/2 and then click next to load domain/pyisp/menu/3, would
> these instructions :
>
> domains = g.objects.all()
> paginator = ObjectPaginator(domains, 10)
>
> hit the DB again?? if it does, what would be the best practice in order to
> keep everythong in memory to avoid accessing the database everytime I click
> next or previous??
>
> thank you very much for your help
> jhv
>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination: how to find out on what page a give object will end up

2008-05-09 Thread Juanjo Conti

VidJa Hunter escribió:
> 
> paginator.is_on_page(object) would return page 6 if object is element 31 of
> the given queryset.
> 

I am leaving right now, but, what about something like this?

for page in paginator.page_range:
if object in paginator.page(page).object_list:
return page

Greets!

Juanjo
-- 
mi blog: http://www.juanjoconti.com.ar

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination documentation unclear

2007-10-11 Thread Steve Potter

On Oct 11, 5:43 pm, johnny <[EMAIL PROTECTED]> wrote:
> I was going over documentation on pagination and it mentions you can
> do it in two ways as follows:
>
> URL... ?page=x
> or
> (r'^objects/page(?P[0-9]+)/$', 'object_list', dict(info_dict))
>
> My question is, you would use
>
> "URL... ?page=x" for regular views?
>
> "(r'^objects/page(?P[0-9]+)/$', 'object_list', dict(info_dict))"
> for generic views?
>
> object_list is the function in django.views.generic.list_detail ?
>
> What is dict(info_dict) do?
>
> what is objects in "(r'^objects/page(?P[0-9]+)/$'", model name?

Johnny,

This example is just trying to demonstrate that you can either
paginate urls by using http://www.example.com/somepage/?page=2, or you
can use something like http://www.example.com/somepage/2/ neither one
is restricted to custom or generic views it is all about how you
configure your urls.py.

Steve


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination for search result ...

2007-08-10 Thread LaundroMat

request["filter"] is a session variable, that's why it works :)

On Aug 10, 5:25 am, "Kai Kuehne" <[EMAIL PROTECTED]> wrote:
> On 8/10/07, james_027 <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > hi,
>
> > > def list_filter(request):
> > > """Update session filter"""
> > > # request['filter'] is a hidden field. frankly, I don't know if
> > > this is really needed.
> > > # I added it in case I add another form to the template
> > > if request.method == 'POST' and request['filter'] == '1':
> > > request.session['filter_title'] = request.POST['title']
> > > request.session['filter_genre'] = request.POST['genre']
> > > request.session['filter_rating'] = request.POST['rating']
> > > return HttpResponseRedirect('/')
>
> > thanks kai :). is this request['filter'] a django builtin or u just
> > created it?
>
> No, I added it. It's a hidden field just to check that's the filter
> that is fired up and not another form on the page.
>
> To tell the truth, this should be request.POST['filter'] and I
> don't really know why request['filter'] worked. Thanks for
> pointing that out. :-)
>
> Kai


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination for search result ...

2007-08-09 Thread james_027

hi,

On Aug 10, 11:25 am, "Kai Kuehne" <[EMAIL PROTECTED]> wrote:
> On 8/10/07, james_027 <[EMAIL PROTECTED]> wrote:
>
>
>
>
>
> > hi,
>
> > > def list_filter(request):
> > > """Update session filter"""
> > > # request['filter'] is a hidden field. frankly, I don't know if
> > > this is really needed.
> > > # I added it in case I add another form to the template
> > > if request.method == 'POST' and request['filter'] == '1':
> > > request.session['filter_title'] = request.POST['title']
> > > request.session['filter_genre'] = request.POST['genre']
> > > request.session['filter_rating'] = request.POST['rating']
> > > return HttpResponseRedirect('/')
>
> > thanks kai :). is this request['filter'] a django builtin or u just
> > created it?
>
> No, I added it. It's a hidden field just to check that's the filter
> that is fired up and not another form on the page.
>
> To tell the truth, this should be request.POST['filter'] and I
> don't really know why request['filter'] worked. Thanks for
> pointing that out. :-)
>
> Kai

THanks for all of this!

cheers,
james


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination for search result ...

2007-08-09 Thread Kai Kuehne

On 8/10/07, james_027 <[EMAIL PROTECTED]> wrote:
>
> hi,
>
> > def list_filter(request):
> > """Update session filter"""
> > # request['filter'] is a hidden field. frankly, I don't know if
> > this is really needed.
> > # I added it in case I add another form to the template
> > if request.method == 'POST' and request['filter'] == '1':
> > request.session['filter_title'] = request.POST['title']
> > request.session['filter_genre'] = request.POST['genre']
> > request.session['filter_rating'] = request.POST['rating']
> > return HttpResponseRedirect('/')
> >
>
> thanks kai :). is this request['filter'] a django builtin or u just
> created it?

No, I added it. It's a hidden field just to check that's the filter
that is fired up and not another form on the page.

To tell the truth, this should be request.POST['filter'] and I
don't really know why request['filter'] worked. Thanks for
pointing that out. :-)

Kai

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination for search result ...

2007-08-09 Thread james_027

hi,

> def list_filter(request):
> """Update session filter"""
> # request['filter'] is a hidden field. frankly, I don't know if
> this is really needed.
> # I added it in case I add another form to the template
> if request.method == 'POST' and request['filter'] == '1':
> request.session['filter_title'] = request.POST['title']
> request.session['filter_genre'] = request.POST['genre']
> request.session['filter_rating'] = request.POST['rating']
> return HttpResponseRedirect('/')
>

thanks kai :). is this request['filter'] a django builtin or u just
created it?

james


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination for search result ...

2007-08-09 Thread Kai Kuehne

Hi,

On 8/10/07, james_027 <[EMAIL PROTECTED]> wrote:
> Hi Kai,
> Could you share you code how your save your filter in session?

Yes:
def list_filter(request):
"""Update session filter"""
# request['filter'] is a hidden field. frankly, I don't know if
this is really needed.
# I added it in case I add another form to the template
if request.method == 'POST' and request['filter'] == '1':
request.session['filter_title'] = request.POST['title']
request.session['filter_genre'] = request.POST['genre']
request.session['filter_rating'] = request.POST['rating']
return HttpResponseRedirect('/')

> THanks
> james

Greetings :)
Kai

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination for search result ...

2007-08-09 Thread james_027

Hi Kai,

>
> Do you mean that the filter works on the first page but
> is lost when you go to another page? If yes:
> I save my filter in a session and filter on each page using
> that filter values (the values that were given to the input fields
> of the filter form). I don't know whether this is the right way (tm)
> but it works for me. :-)
>

Could you share you code how your save your filter in session?

THanks
james


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: pagination for search result ...

2007-08-09 Thread Kai Kuehne

Hi James,

On 8/9/07, james_027 <[EMAIL PROTECTED]> wrote:
>
> hi,
>
> I am trying to put a page list for a search result. So far here's what
> I've try by using the django.views.generic.list_detail.object_list and
> the pagination tag (http://code.djangoproject.com/wiki/PaginatorTag)
> and later found out that it won't meet my needs.
>
> def search_employee(request):
> if not request.GET:
> return render_to_response('search_employee.htm')
> else:
> params = request.GET['name'].split()
> employees = Employee.objects.all()
> for p in params:
> employees = employees.filter(Q(firstname = p) | Q(lastname
> = p))
> return object_list(request, employees, paginate_by=3,
> template_name='search_employee_result.htm',
> template_object_name='employee')
>
> This won't work because when you try to select other page the
> query_set from previous is lost ... I am thinking off passing the
> request.GET to the object_list's extra_context argument, then edit the
> pagination tag that will provide link constrcuted from the
> extra_context?
>
> Or is there a better solution or existing solution?

Do you mean that the filter works on the first page but
is lost when you go to another page? If yes:
I save my filter in a session and filter on each page using
that filter values (the values that were given to the input fields
of the filter form). I don't know whether this is the right way (tm)
but it works for me. :-)

> Thanks
> james

Greetings
Kai

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination

2007-06-21 Thread Forest Bond
On Thu, Jun 21, 2007 at 11:04:40PM -, Rob Hudson wrote:
> 
> Just following up...
> 
> If you use the query string option, you don't need to know the current
> url, you can just do this:
> 
> {% if has_previous %}
> Previous
> {% endif %}

Which works fine & dandy as long as you're not using GET parameters for anything
else.  The canonical example is a search page with paginated results.  It's
actually a slight pain to come up with a good way to construct the prev/next
URLs without making too many assumptions about the order/presence of GET
parameters.  I'd be happy if django would come up with a nice solution to that
problem.

I'd also be happier if django's pagination template context parameters didn't
pollute the template context so much.  It'd be nice to stuff them all in a dict
called paginator:

{{paginator.next}}

etc.

But idunno, I guess it's not that big of a deal.  In practical terms, it
probably doesn't actually come up, since you can just avoid name conflicts by
not naming your context variables the same as the pagination variables.

-Forest


signature.asc
Description: Digital signature


Re: Pagination

2007-06-21 Thread Rob Hudson

Just following up...

If you use the query string option, you don't need to know the current
url, you can just do this:

{% if has_previous %}
Previous
{% endif %}

And the browser fills in the current url path minus any query string
and that just appends to it, which is kind of nice.

I like the clean URL of: /url/page2/

But I like how this works better in the template: /url/?page=2

Unless I'm missing something which I thought I might be.

Perhaps the pagination stuff could add support for building URLs for
you in either case and add "prev_url" and "next_url" to the context?
Then either way is a no brainer for template authors.

-Rob


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination

2007-06-21 Thread Bryan L. Fordham


> I don't understand. If you're one /foo/bar/baz/page1/, then why can't
> you write  as the link? It will work, is a
> well-formed URL and is independent of the prefix. Note that you must
> ensure your URLs are canonicalised if you use this system, though:
> always ending with a trailing slash, so that the "../" will go to the
> right place.
>   
that will work of the first page is /foo/bar/baz/page1/  and not 
/foo/bar/baz/



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination

2007-06-21 Thread Rob Hudson

> I don't understand. If you're one /foo/bar/baz/page1/, then why can't
> you write  as the link? It will work, is a
> well-formed URL and is independent of the prefix. Note that you must
> ensure your URLs are canonicalised if you use this system, though:
> always ending with a trailing slash, so that the "../" will go to the
> right place.

Ah, that's what I was looking for.  I hadn't thought about that.
Thanks!

And thanks for the extra note on the extra bit of checks -- I'll keep
an eye out.

-Rob


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination

2007-06-21 Thread Malcolm Tredinnick

On Thu, 2007-06-21 at 21:10 +, Rob Hudson wrote:
> On Jun 21, 1:23 pm, Tyson Tate <[EMAIL PROTECTED]> wrote:
> > Look at "next" and "previous" context variables. You can do:
> >
> > Next
> >
> > and
> >
> > Previous
> 
> Right, but it's the 'href="/url/..."' part that doesn't feel right to
> me.  If I either want to (a) re-use this template for other URLs (list
> view by tag, list view by date, etc) or (b) decide later that I want /
> url/ to be /foo/ in urls.py, then I have to remember to change the
> template, which I don't trust myself to do.

I don't understand. If you're one /foo/bar/baz/page1/, then why can't
you write  as the link? It will work, is a
well-formed URL and is independent of the prefix. Note that you must
ensure your URLs are canonicalised if you use this system, though:
always ending with a trailing slash, so that the "../" will go to the
right place.

Regards,
Malcolm



--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination

2007-06-21 Thread Rob Hudson

On Jun 21, 1:23 pm, Tyson Tate <[EMAIL PROTECTED]> wrote:
> Look at "next" and "previous" context variables. You can do:
>
> Next
>
> and
>
> Previous

Right, but it's the 'href="/url/..."' part that doesn't feel right to
me.  If I either want to (a) re-use this template for other URLs (list
view by tag, list view by date, etc) or (b) decide later that I want /
url/ to be /foo/ in urls.py, then I have to remember to change the
template, which I don't trust myself to do.

I was kind of expecting to find in the pagination context variables a
prev_url and next_url I could use and not have to build my own in the
template.  I don't see all the pieces I'd need to make the /url/ part
be more dynamic.

Thanks,
Rob


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination

2007-06-21 Thread Tyson Tate

Look at "next" and "previous" context variables. You can do:

Next

and

Previous

to get what you want, as long as you've set up the URL regexes  
properly in urls.py. You'll want to surround each of the above with  
an if block to check and see if you do, indeed, have a next or  
previous page ("has_next" and "has_previous").

-Tyson

On Jun 21, 2007, at 1:11 PM, Rob Hudson wrote:

>
> I've set up a list view that I want paginated and I'm using the
> list_detail generic view.  I was thinking that I would prefer the / 
> url/
> page2/ URL over /url?page=2 so I set that up.  The problem is, in my
> template where I want to display the prev/next links there's no way
> that I see to avoid hard coding the "url" part of the path to the next
> and prev pages.
>
> With this in mind, it seems like the ?page=2 option is preferred.
>
> Is this right?  What are the pros/cons of one over the other?  *Is*
> there a way to get the URL prefix up to the /page2/ part?
>
> Thanks,
> Rob

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination causing mySQL error

2007-05-04 Thread Pashka R.

hm... you can check amount of the records before output... why not?


2007/5/4, Merric Mercer <[EMAIL PROTECTED]>:
>
> I have a template that has 3 non-contiguous areas.   I need to display
> the results of a query set across these three areas.
> My initial solution was to split up the query set in the template using
> "slice". For example:
>
> {% for object in object_list|slice:"1:6" %}area one {% endfor %}
> {% for object in object_list|slice:"6:9" %}area two {% endfor %}
> etc
>
> My problem is that this is not working with pagination correctly when
> the pagination returns less than the initial slice ( in this case 6).  I
> get the following errors (see below).
>
> Can anybody suggest how to avoid this? Many thanks
>
> MerMer
>
>
>
> Caught an exception while rendering.{% for object in
> object_listslice:"3:6" %}
> Exception Type: ProgrammingError
> Exception Value: (1064, "You have an error in your SQL syntax; check the
> manual that corresponds to your MySQL server version for the right
> syntax to use near '-1' at line 1")
> Exception Location: C:\Python24\Lib\site-packages\MySQLdb\connections.py
> in defaulterrorhandler, line 35
>
> >
>


-- 
//wbr Pashka R. <[EMAIL PROTECTED]>

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination variable problem with generic list and limited queryset

2006-12-04 Thread Silas

Thanks for the explanation Rajesh.

On Dec 4, 2:31 pm, "RajeshD" <[EMAIL PROTECTED]> wrote:
> On Dec 3, 8:36 pm, "Silas" <[EMAIL PROTECTED]> wrote:
>
> > I have a problem with generic.list_detail.object_list, a limiting
> > queryset, and pagination variables.
>
> > For some reason when I use the code below, results are restricted to
> > the sliced 100, but all the pagination variables show results as if the
> > slice wasn't there.I don't have a solution, but I can explain the reason 
> > for this
> behaviour.
>
> - The ObjectPaginator uses the QuerySet.count() method in deriving the
> 'hits' count that is then used in all its paging calculations
> - The QuerySet.count() method does not take into account the slice
> offset and limit
>
> I suppose you could file this as a bug in ObjectPaginator -- if it were
> to base its hits on len(QuerySet), that would solve this problem. Not
> sure if there would be a performance issue from len() evaluating the
> QuerySet.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination variable problem with generic list and limited queryset

2006-12-04 Thread RajeshD

On Dec 3, 8:36 pm, "Silas" <[EMAIL PROTECTED]> wrote:
> I have a problem with generic.list_detail.object_list, a limiting
> queryset, and pagination variables.
>
> For some reason when I use the code below, results are restricted to
> the sliced 100, but all the pagination variables show results as if the
> slice wasn't there.
>

I don't have a solution, but I can explain the reason for this
behaviour.

- The ObjectPaginator uses the QuerySet.count() method in deriving the
'hits' count that is then used in all its paging calculations
- The QuerySet.count() method does not take into account the slice
offset and limit

I suppose you could file this as a bug in ObjectPaginator -- if it were
to base its hits on len(QuerySet), that would solve this problem. Not
sure if there would be a performance issue from len() evaluating the
QuerySet.


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination with Custom Views

2006-11-18 Thread [EMAIL PROTECTED]

That was supposed to go into a separate topic.. sorry!


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination with Custom Views

2006-11-17 Thread soundseeker

holy ... , how stupid.
but it led not to the solution, which is:
TMergeDoc().by_categories()

I had to instantiate the object, of course.

Now there are some paginator problems I have to analyze.

thank you very much so far!

robert


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Re: Pagination with Custom Views

2006-11-16 Thread James Bennett

On 11/16/06, soundseeker <[EMAIL PROTECTED]> wrote:
> I'm desperately searching for a solution as described here (paginator +
> costom sql):

In the example you've posted, the method name is 'by_categories', but
you seem to be using 'by_category' to execute it. A method named
'by_categories' will always be called 'by_categories', never
'by_category'.

-- 
"May the forces of evil become confused on the way to your house."
  -- George Carlin

--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination with Custom Views

2006-11-16 Thread soundseeker

hello,
I'm desperately searching for a solution as described here (paginator +
costom sql):
http://groups.google.com/group/django-users/browse_frm/thread/1aa04d3ab8fc9203/ab1384a82c9d5508#ab1384a82c9d5508
and here:
http://groups.google.com/group/django-users/browse_frm/thread/d6690c92c5b7347e/7985a43df0f8b43a#7985a43df0f8b43a

... and I still can't find out, what's wrong.
Maybe you are able to answer... thank you in advance!

robert


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination with Custom Views

2006-11-16 Thread Ivan Sagalaev

[EMAIL PROTECTED] wrote:
> Specifically:
> 
> unsupported operand type(s) for -: 'str' an

Oh... I've forgot to cast a string to an int :-). The line:

 int(request.GET.get('page', '1'))

In fact you should also check for errors here because user can submit 
something with "page=blah" and it won't be converted to an integer 
obviously. I assign 1 to a page in this case.

--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination with Custom Views

2006-11-16 Thread [EMAIL PROTECTED]

Sorry, I meant:

unsupported operand type(s) for -: 'str' and 'int'

[EMAIL PROTECTED] wrote:
> Specifically:
> 
> unsupported operand type(s) for -: 'str' an


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination with Custom Views

2006-11-16 Thread [EMAIL PROTECTED]

Ivan: Thanks so much for your quick reply. One more question - how
would I define the page in the URL... ?page=x throws errors at me


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination with Custom Views

2006-11-16 Thread [EMAIL PROTECTED]

Specifically:

unsupported operand type(s) for -: 'str' an


--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination with Custom Views

2006-11-16 Thread Ivan Sagalaev

[EMAIL PROTECTED] wrote:
> Hey,
> 
> I was just wondering if someone could help me out. I want to paginate
> some views, but they are not generic. This is one of the views I want
> to paginate:
> 
> def category_list(request):
>   categories = Category.objects.order_by('name')
> 
>   return shortcuts.render_to_response("blog/category_list.html",
> dict(categories = categories))
> 
> How would I go about paginating that?

Like this:

 from django.core.paginator import ObjectPaginator, InvalidPage

 def category_list(request):
   paginator = ObjectPaginator(Category.objects.order_by('name'), 50)
   try:
 page = request.GET.get('page', 1)
 categories = paginator.get_page(page - 1)
   except InvalidPage:
 categories = []
   return render_to_response('template.html', {
 'paginator': paginator,
 'page': page,
 'categories': categories,
   }, context_instance=RequestContext(request))

--~--~-~--~~~---~--~~
 You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en
-~--~~~~--~~--~--~---



Re: Pagination and relative URLs

2006-07-21 Thread limodou
On 7/22/06, Maciej Bliziñski <[EMAIL PROTECTED]> wrote:
>
> The Django documentation refers to the pagination:
> http://www.djangoproject.com/documentation/generic_views/#notes-on-pagination
>
> And suggests following pagination scheme:
>
> ^objects/ -- object list, first page
> ^objects/page2/ -- second page
> ^objects/page3/ -- third page, and so on
>
> Let's say I'm creating pagination. I have designed the object list
> template, which has:
>
> {% if has_next %}
> next
> {% endif %}
>
> This template would link correctly from ^objects/ to ^objects/page2/.
> But unfortunately, it would link from ^objects/page2/ to
> ^objects/page2/page3/ (wrong).
>
> So if I wrote:
>
> {% if has_next %}
> next
> {% endif %}
>
> It would link from ^objects/page2/ to ^objects/page3/ but unfortunately,
> it would also link from ^objects/ to ^/ (wrong).
>
> Which solution is best in your opinion?
>
>   * Absolute links? (I'm using them right now and was in trouble
> already because of that)

I think it's the easiest solution.

>   * Redirect from ^objects/ to ^objects/page1/?
>   * Custom view for URL scheme ^objects/pageX/ that defines a
> variable which indicates that ../ should be used?
>   * Other solution?
>
I ever using base tag in template, just like:



...


so all the relative link with based on base link. Maybe this would be helpful.

-- 
I like python!
My Blog: http://www.donews.net/limodou
My Django Site: http://www.djangocn.org
NewEdit Maillist: http://groups.google.com/group/NewEdit

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Pagination - displaying page numbers

2006-03-23 Thread limodou

On 3/24/06, Stephen <[EMAIL PROTECTED]> wrote:
>
> Hello,
>
> I've just started looking at Django, it's certainly looking like a very
> good choice for the sort of projects I'll be doing in the near future.
>
>
> Just now I've been looking at pagination and have a question:
>
> I'm using the generic view "list_detail" to view a list of results.  I
> want to use pagination to restrict the number of items on a page.  To
> do this I've added a "paginate_by" value to the info_dict dictionary in
> my urls.py file.  This results in my results being paginated correctly,
> and the additional context parameters are available in my template.  I
> can use these to show how many hits there were and how many pages of
> results etc there are.  My problem comes with trying to show a numbered
> link to each page of results (like google does at the bottom of its
> results page).  I thought this would be straightforward - just do a
> loop - but as far as I can see the {% for %} tag can only iterate over
> an array, and the "pages" context property is a number.  What is the
> right way to go about looping from N to N+M in a template ?  My feeling
> is that looping over a list is the nicest way, but then I can't get the
> pagination to work like I want!  Apologies if I'm missing something
> really obvious!
>
> In the course of trying to figure this out I tinkered around with the
> list_detail.py file and tried adding extra context parameters (e.g.
> 'page_list':range(1, pages+1, 1) ).  These never showed up in my
> templates though - are there specific steps to take in order to make
> changes to the django source files be noticed by the server (I'm using
> the test server that comes with Django)?
>
> Thanks in advance for any help,
>
> Stephen.
>
>

One way I think is just like what you do: create a extra_context.

The other way is create a custom tag to create a list. Someone has
submit this patch before. http://code.djangoproject.com/ticket/1162

Or you can use a custom tag written by me to calculate the list in
template: expr tag

http://groups.google.com/group/django-users/browse_thread/thread/6c1c162e7dd5d0d8/ce3aa7e2e3d48ae1?lnk=st&q=an+expression+tag&rnum=3#ce3aa7e2e3d48ae1

{% expr range(pages) as page_number %}
{% for i in page_number %}
...
{% endfor %}
--
I like python!
My Blog: http://www.donews.net/limodou
NewEdit Maillist: http://groups.google.com/group/NewEdit

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---



Re: Pagination - displaying page numbers

2006-03-23 Thread Stephen

The answer to the second part of my question *was* very obvious... I
was editing the wrong copy of the source file.  I needed to change the
copy installed under my Python directory, not the one in the Django
directory.


--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at 
http://groups.google.com/group/django-users
-~--~~~~--~~--~--~---