[Python] get random orderd query based on a day number in Django python

Discussão em 'Python' iniciado por Stack, Fevereiro 21, 2025.

  1. Stack

    Stack Membro Participativo

    i have a product page that have infinit paginate that using scroll triger function to load new products on page right now it just show the normal order based on the product name i want every day users can see diffrent order of products in the page problem is if i use :

    from django.db.models.functions import Random
    products = Product.objects.all().order_by('-available', Random())
    products = products.prefetch_related(
    Prefetch('colors', queryset=ProductColor.objects.order_by('-quantity'))
    )


    when new products adding in the page view will call and also my quey set is calling again and i get new randominzed product list and users will see duplicate products how can i get randomized quey set fixed for each day ?

    Continue reading...

Compartilhe esta Página