Django Bringing Data from a Model to Another Model Django.How

Author avatar wrote on 26/05/2022

Assuming that we need to bring listings from the listings model and show it on the home page which is a part of another model pages

We get the last three listings to show them on the home page pages/views.py

Multiple lists in context


def about(request):
    realtors = Realtor.objects.order_by('-hire_date')
    mvp_realtors = Realtor.objects.all().filter(is_mvp=True)
    context = {
        'realtors' : realtors,
        'mvp_realtors' :mvp_realtors
    }
    return render(request, 'pages/about.html', context)
CRUDgen Django CRUD generator