vendredi 26 juin 2020

How to add multiple types of objects in a class

Here, is the problem when I try to add multiple objects to context through get function it is not showing pagination and when views.py is like below code then I am unable to add multiple objects of different models. Ex: I want to add two models like Items and Ads to my Homepage class then how can I do this. Views.py

class HomeView(ListView):
    model = Item
    paginate_by = 12
    template_name = "home.html"

home.html

<div class="card-body text-center">
                <a href="" class="grey-text">
                  <h5></h5>
                </a>
                <h5>
                  <strong>
                    <a href="" class="dark-grey-text">
                      <span class="badge badge-pill -color"></span>
                    </a>
                  </strong>
                </h5>

                <h4 class="font-weight-bold black-text">
                  <strong>
                  
                  
                  
                  </strong>
                </h4>

              </div>



Aucun commentaire:

Enregistrer un commentaire