Hello,

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

here is the code

models.py

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

Views.py

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

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

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

     all_information=query.random(1000)


Regards,

Damanjeet


On Sun, Jul 12, 2020 at 7:57 PM MUGOYA DIHFAHSIH <[email protected]>
wrote:

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

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAGLHGi6sn6T1AFE6RF%2BPCuiv9Sy%3DkEi_Q-PDLUWQom%3DhByjhOw%40mail.gmail.com.

Reply via email to