Re: Confused with django model Limit and Offset Implementation

2012-01-27 Thread Swaroop Shankar V
got it working thanks anyway :)

Thanks and Regards,
Swaroop Shankar V



On Mon, Jan 23, 2012 at 12:00 PM, Leandro Ostera Villalva <
leost...@gmail.com> wrote:

> AFAIK it is [offset:page]
>
> El 22 de enero de 2012 20:40, Swaroop Shankar V escribió:
>
>> Hi,
>> Am trying to create a custom pagination for my project, but am seriously
>> struck with the django implementation of Limit and offset. I went through
>> the documents, instead of making me understand how it works, i ended up
>> more confused. So suppose I have a page limit of 3 records per page and if
>> i want to load the second set of records how should the following statement
>> be?
>>
>> Data = NewsFeedStory.objects.order_by('-updated_on')[?:?]
>>
>> and similarly if i want to load the 3rd set with same page limit, how
>> should the same statement be? I played with the django shell to figure out
>> how this works but am still confused. Please help.
>>
>> Thanks and Regards,
>>
>> Swaroop Shankar V
>>
>>  --
>> 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.
>>
>
>
>
> --
> Regards,
>
> Leandro Ostera,
> *BLOG - Check what I'm doing now 
> EMAIL - Write me an email 
> SHOWCASE - Check my latest projects *
>
>  --
> 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.
>

-- 
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: Confused with django model Limit and Offset Implementation

2012-01-27 Thread Leandro Ostera Villalva
AFAIK it is [offset:page]

El 22 de enero de 2012 20:40, Swaroop Shankar V escribió:

> Hi,
> Am trying to create a custom pagination for my project, but am seriously
> struck with the django implementation of Limit and offset. I went through
> the documents, instead of making me understand how it works, i ended up
> more confused. So suppose I have a page limit of 3 records per page and if
> i want to load the second set of records how should the following statement
> be?
>
> Data = NewsFeedStory.objects.order_by('-updated_on')[?:?]
>
> and similarly if i want to load the 3rd set with same page limit, how
> should the same statement be? I played with the django shell to figure out
> how this works but am still confused. Please help.
>
> Thanks and Regards,
>
> Swaroop Shankar V
>
>  --
> 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.
>



-- 
Regards,

Leandro Ostera,
*BLOG - Check what I'm doing now 
EMAIL - Write me an email 
SHOWCASE - Check my latest projects *

-- 
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: Confused with django model Limit and Offset Implementation

2012-01-23 Thread Daniel Roseman
On Monday, 23 January 2012 04:40:31 UTC, Swaroop Shankar wrote:
>
> Hi,
> Am trying to create a custom pagination for my project, but am seriously 
> struck with the django implementation of Limit and offset. I went through 
> the documents, instead of making me understand how it works, i ended up 
> more confused. So suppose I have a page limit of 3 records per page and if 
> i want to load the second set of records how should the following statement 
> be?
>
> Data = NewsFeedStory.objects.order_by('-updated_on')[?:?]
>
> and similarly if i want to load the 3rd set with same page limit, how 
> should the same statement be? I played with the django shell to figure out 
> how this works but am still confused. Please help.
>
> Thanks and Regards,
>
> Swaroop Shankar V
>
>
I'm not sure why this should confuse you. You seem to have correctly 
understood the syntax. 

This is just normal Python slicing, which Django transforms into LIMIT and 
 OFFSET. So, remembering that Python slicing is 0-based and the lower bound 
is inclusive but the upper is exclusive, the first page is [:3], the second 
page is [3:6], the third is [6:9], etc.

Note, however, that if you're doing pagination, you should really be using 
the built-in Paginator class [1], which calculates all this for you given a 
page number, rather than doing it yourself.

 [1]: https://docs.djangoproject.com/en/1.3/topics/pagination/
--
DR.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To view this discussion on the web visit 
https://groups.google.com/d/msg/django-users/-/NDDsTmr8iDoJ.
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.



Confused with django model Limit and Offset Implementation

2012-01-22 Thread Swaroop Shankar V
Hi,
Am trying to create a custom pagination for my project, but am seriously
struck with the django implementation of Limit and offset. I went through
the documents, instead of making me understand how it works, i ended up
more confused. So suppose I have a page limit of 3 records per page and if
i want to load the second set of records how should the following statement
be?

Data = NewsFeedStory.objects.order_by('-updated_on')[?:?]

and similarly if i want to load the 3rd set with same page limit, how
should the same statement be? I played with the django shell to figure out
how this works but am still confused. Please help.

Thanks and Regards,

Swaroop Shankar V

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