Slicing a list like you are trying to do is calling a pagination.
Django have a few tools for dealing with this problem. Here is a link
to the documentation:
https://docs.djangoproject.com/en/1.11/topics/pagination/

If you have any trouble using it, don't hesitate to ask for more details :)

2017-04-15 11:50 GMT+02:00  <anonymousco...@gmail.com>:
> I am using jquery to present a number of products as per user's selection on
> "Show" dropdown menu. If user selects to get 9, 12, 16 or 20 products per
> page it should show accordingly in my list view.
>
> Following is the code for HTML:
>
> <form>
> <span>Show:</span>
> <select class="orderby number" name="page_size">
>                                                <option value="9"
> selected="selected">9</option>
>                                                <option
> value="12">12</option>
>                                                <option
> value="24">24</option>
>                                                <option
> value="36">36</option>
>                                                <option
> value="48">48</option>
>                                                <option
> value="60">60</option>
>                                                <option
> value="90">90</option>
>                                                <option
> value="100">100</option>
> </select>
> </form>
>
> My list view varibale is:
>
> items = Items.objects.all().
>
> How can I restrict to load products according to the user's selected number
> of products?
> Please help.
>
> Regards,
> A
>
> --
> 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/f34f0f5e-b7d6-4701-8a79-0f38bce4f7b5%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.



-- 

Cordialement, Ludovic Coues
+33 6 14 87 43 42

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAEuG%2BTbb60D%2B_0zRZyvsAEk2%2BrOUWuiOj_S2sjG2QbqhiPiw_w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to