code question

10 views
Skip to first unread message

frank dilorenzo

unread,
Jun 29, 2021, 3:57:17 PM6/29/21
to Django users
Here is a function view:

def base(request):

    shipments = Shipment.objects.all().order_by("-slabel")[:5]

    suppliers = Supplier.objects.all()


    context = {

        "shipments": shipments,

        "suppliers": suppliers,

    }

    return render(request, "base/dashboard.html", context)


I tried to figure this out myself but apparently I can't.  I want to convert this to a class based view if possible but I couldn't figure out how to send the context data to the .html file.  Not sure it that is even possible.  I am new to django for sure.


Frank

Lalit Suthar

unread,
Jun 29, 2021, 8:58:23 PM6/29/21
to django...@googlegroups.com

--
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...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/95d0558e-5f34-4e81-b20c-c95aee4af739n%40googlegroups.com.

frank dilorenzo

unread,
Jun 30, 2021, 12:43:42 AM6/30/21
to django...@googlegroups.com
I thought I had been everywhere on the web but guess not.  This really helped me a lot and I have it working now. Thanks a lot!

frank-


Reply all
Reply to author
Forward
0 new messages