I don't presume to be an expert by any means, but doesn't your view pass a
queryset to the template, which the pagination template tags operate on
further (probably using the built in pagination lib)?
If that is the case, what's the difference between passing the queryset into
the pagination lib in the view vs in a template tag?
To me pagination is a presentation issue anyway. You're showing the person a
list of things, but 99% of people aren't going to look past the first x
things, so we just show them that much.
It also makes the pages load faster.
Passing the full queryset can make the code more readable especially if you
are going to put something like {{ search_result_queryset.count }}
Just my two cents (though I find myself using the object list generic view
whenever pagination comes up anyway)
Jim
On Sun, Oct 25, 2009 at 12:41 PM, Bob Waycott <[email protected]> wrote:
> With all due respect, handling pagination at the template level is NOT a
> good idea. This is offering a pretty lazy way to create paginated product
> listings.
>
> Case in point: Category X has 1,000 products in it. Given this proposed
> method, the category view would return 1,000 products when someone visits
> /category/x/ and then leave it to a template tag to auto-mangle that list
> to, say, 10 products? That's not programming, that's just lazy.
>
> The right way to complete any task is to complete it with the right
> approach, regardless of a particular implementation "style." Offering a
> paginated category listing in a custom format that does not touch Satchmo
> code should be done via a view and only a view. This way, if your pagination
> requirements are 10 products per page, the view only returns 10 products to
> be processed by the template, not 1,000.
>
> Templatetags (which is what django-pagination is) should be used to do
> minor presentation-focused manipulations of data returned from a view. They
> should not be given the task of performing logic-related manipulations of
> said data.
>
> The reason "there doesn't seem to be a performance hit using
> django-pagination" is that you're not using a big enough result set and you
> are using a wrong metric of evaluation.
>
> Performance is never a valid indicator of correctly solving a problem.
>
> Mike, if at any point in a Django project you want to paginate results, it
> is always correct to do so via views. Start with Django's built-in
> pagination lib that is documented at djangoproject.com -- extend it in
> your projects to customize its behavior further. You don't want to start
> relying on templates to do your pagination. Just use the templates to
> customize your paginated result set that is returned from your view.
>
>
> On Sun, Oct 25, 2009 at 7:26 AM, Iain Mac Donald <
> [email protected]> wrote:
>
>>
>> On Sat, 24 Oct 2009 16:44:31 -0700 (PDT)
>> mike <[email protected]> wrote:
>>
>> > does anyone have an example on how to do pagination in /category/*
>> > pages without modifying satchmo source?
>>
>> - install django-pagination
>>
>> - add 'pagination', to installed apps
>>
>> - make sure that 'django.core.context_processors.request', is listed in
>> TEMPLATE_CONTEXT_PROCESSORS
>>
>> - add {% load pagination_tags %} near the top of your template e.g.
>> templates/product/category.html (having previously copied this template
>> from Satchmo to your project directory and edit it there).
>>
>> - further down your template file, where you want the pagination to
>> happen, add something like this
>>
>> ...
>> {% autopaginate products 4 %}
>> {% for product in products %}
>> ...
>>
>> - make sure your pagination stuff is enclosed in the pagination CSS div.
>>
>> - reload your page and enjoy paginated results.
>>
>> You could write everything yourself using Django's built in pagination
>> as, for example, has been done with the "Featured items" in the "Large"
>> example project but I haven't worked that one out yet. However, as far
>> as I can tell there doesn't seem to be a performance hit using
>> django-pagination.
>>
>> Regards,
>> Iain.
>>
>>
>>
>
> >
>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Satchmo users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/satchmo-users?hl=en
-~----------~----~----~----~------~----~------~--~---