Ok. Simple exemple.
data_1 = Model_1.objects.all() data_2 = Model_2.objects.all() data_3 = Model_3.objects.all() data_4 = Model_4.objects.all() data_5 = Model_5.objects.all() data_6 = Model_6.objects.all() context = { 'data_1': data_1, 'data_2': data_2, 'data_3': data_3, 'data_4': data_4, 'data_5': data_5, 'data_6': data_6, } return render(request, 'yourpage.html, context) #### Replaces Model_1 ... Model_6 by your models you want to send in your view. Invite your template use data_1,..., data_6 Le jeu. 15 août 2019 à 19:28, Kean <kean...@gmail.com> a écrit : > Hi N’BE, > > If I have 6 objects in my dbase model, I would want all six to be returned > to the view, via template. > > However, the code you sent is only returning 1 object, so i am missing 5 > > how can I use the view code, to ensure all 6 are returned o the template? > > Best, > > K > > > On 15 Aug 2019, at 20:21, N'BE SORO <soro4...@gmail.com> wrote: > > you want to send what model on your view? > > Le jeu. 15 août 2019 à 19:04, Kean <kean...@gmail.com> a écrit : > >> Hi N’BE, >> >> Thanks, the code worked, the problem is I wanted to use the context to >> return all objects in the database to >> the defined html view, >> >> However, I am still only getting the self defined str and returning to >> view, is there any way to get all records in the table to display? >> >> Best, >> >> Kea >> >> On 15 Aug 2019, at 19:50, N'BE SORO <soro4...@gmail.com> wrote: >> >> Hello Use this code >> >> >> def editremovebusiness(request): >> data = Businessownercreate.objects.all() >> context = { >> 'data': data, >> } >> return render(request, 'editremovebusiness.html', context) >> >> Le jeu. 15 août 2019 à 18:45, RONAK JAIN <jainronak...@gmail.com> a >> écrit : >> >>> Hey Kean, >>> >>> What is the object here? >>> >>> >>> >>> >>> On Thu, Aug 15, 2019 at 11:37 PM Kean <kean...@gmail.com> wrote: >>> >>>> Hi, >>>> >>>> I have written the following code in views.py >>>> >>>> def editremovebusiness(request): >>>> data = Businessownercreate.objects.all() >>>> context = { >>>> 'Creator': obj.Creator, >>>> 'Micro_Small_Medium': obj.Micro_Small_Medium, >>>> } >>>> return render(request, 'editremovebusiness.html', context={"data":data}) >>>> >>>> when I save it and check the url >>>> >>>> it returns >>>> >>>> Exception Type: NameError >>>> Exception Value: >>>> >>>> name 'obj' is not defined >>>> >>>> >>>> >>>> Is anyone familiar with this issue, please advise cause and fix? >>>> >>>> Best, >>>> >>>> K >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> >>>> -- >>>> 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+unsubscr...@googlegroups.com. >>>> To view this discussion on the web visit >>>> https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com >>>> <https://groups.google.com/d/msgid/django-users/8b426d60-4a54-4ec4-b130-05c0ae69cdd3%40googlegroups.com?utm_medium=email&utm_source=footer> >>>> . >>>> >>> >>> -- >>> 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+unsubscr...@googlegroups.com. >>> To view this discussion on the web visit >>> https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com >>> <https://groups.google.com/d/msgid/django-users/CA%2BAqMUdv39HYFE95ts%3DRyuJdtekr%3D6hPF1KicaaHvmh1FMrq%2Bw%40mail.gmail.com?utm_medium=email&utm_source=footer> >>> . >>> >> >> -- >> 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+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com >> <https://groups.google.com/d/msgid/django-users/CAOtSHp9ufRjCQfUg%2BTCH9ASPaRJtVVS8ik4wq4kJB2wohH1jig%40mail.gmail.com?utm_medium=email&utm_source=footer> >> . >> >> >> >> -- >> 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+unsubscr...@googlegroups.com. >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/3359FAE6-61BE-4E9F-80D4-5BA191EFC382%40gmail.com >> <https://groups.google.com/d/msgid/django-users/3359FAE6-61BE-4E9F-80D4-5BA191EFC382%40gmail.com?utm_medium=email&utm_source=footer> >> . >> > > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAOtSHp_UYM%2Bs_Rk4WEFHjUkEg_VP%2Bri7JczJo4hKRr-mT-14vQ%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAOtSHp_UYM%2Bs_Rk4WEFHjUkEg_VP%2Bri7JczJo4hKRr-mT-14vQ%40mail.gmail.com?utm_medium=email&utm_source=footer> > . > > > -- > 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+unsubscr...@googlegroups.com. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/F3C28CFB-257C-41A4-9B41-5F3FCA59D3D8%40gmail.com > <https://groups.google.com/d/msgid/django-users/F3C28CFB-257C-41A4-9B41-5F3FCA59D3D8%40gmail.com?utm_medium=email&utm_source=footer> > . > -- 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+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAOtSHp-SYGvPhiG9n_e2USTZay-shVkBR2p9mWK5i3brj_6HHg%40mail.gmail.com.