Tuesday, June 29, 2021

Re: code question

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-


On Tue, Jun 29, 2021 at 7:57 PM Lalit Suthar <sutharlalit.97@gmail.com> wrote:

On Wed, Jun 30, 2021, 1:27 AM frank dilorenzo <frankdil92@gmail.com> wrote:
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

--
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+unsubscribe@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.

--
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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAGp2JVFDGwDMMb%2BKJ-SCamJToR2N94B4ENBhL2f5MQyQRhO-iw%40mail.gmail.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+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAJbiy1B1BOnYS4PSkWu8589htbh0v%3D706WE_WjJ%3DPSgKv0bXiw%40mail.gmail.com.

No comments:

Post a Comment