please use the code below: def index(request): context = {}
return render(request, 'index.html' , context) On Thu, 3 Jun 2021 at 16:52, Michael Smith <mich...@24hrselfstorage.com> wrote: > You can't have three of the same name view either can you? > > On Thu, Jun 3, 2021 at 9:36 AM Nandaniya Nilesh < > nileshnandaniya...@gmail.com> wrote: > >> hello, >> I am nilesh, >> i think every funtion should return something. >> >> return dests from index named function. >> last line is not with any function >> >> >> def main(): >> >> ...... >> def index(): >> ...... >> return dest1 >> def index(): >> ...... >> return dest2 >> def index(): >> ...... >> return dest3 >> >> dests = [...] >> return render(.......) >> On Jun 3 2021, at 9:27 am, UJJWAL AGRAWAL <ujjwalgl....@gmail.com> wrote: >> >> Dear team >> >> I am facing a problem with error >> >> While writing this code >> >> ERROR IS: RETURN OUTSIDE FUNCTION >> >> Please help me solving this issue. >> >> from django.shortcuts import render >> from .models import Destination >> # Create your views here. >> def index(request): >> dest1 = Destination() >> dest1.name ='Jaipur' >> dest1.desc ='The pink city Gulaabi nagar' >> dest1.price = 900 >> >> def index(request): >> dest2 = Destination() >> dest2.name ='Udaipur' >> dest2.desc ='The city of lakes' >> dest2.price = 1200 >> >> def index(request): >> dest3 = Destination() >> dest3.name ='Bharatpur' >> dest3.desc ='The city of warriors' >> dest3.price = 1100 >> >> >> dests =[dest1, dest2 , dest3] >> return render(request,"index.html",{'dests':dests}) >> >> >> >> >> -- >> 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 >> <https://link.getmailspring.com/link/fd052ed8-24d7-492d-a0d0-a39a13cba...@getmailspring.com/0?redirect=mailto%3Adjango-users%2Bunsubscribe%40googlegroups.com&recipient=ZGphbmdvLXVzZXJzQGdvb2dsZWdyb3Vwcy5jb20%3D> >> . >> To view this discussion on the web visit >> https://groups.google.com/d/msgid/django-users/CALQ%3D5fxXx_ANP6UxuLcqBtLSuymR2X1F6dUkNQjFpA2ZyG2iOA%40mail.gmail.com >> <https://link.getmailspring.com/link/fd052ed8-24d7-492d-a0d0-a39a13cba...@getmailspring.com/1?redirect=https%3A%2F%2Fgroups.google.com%2Fd%2Fmsgid%2Fdjango-users%2FCALQ%253D5fxXx_ANP6UxuLcqBtLSuymR2X1F6dUkNQjFpA2ZyG2iOA%2540mail.gmail.com%3Futm_medium%3Demail%26utm_source%3Dfooter&recipient=ZGphbmdvLXVzZXJzQGdvb2dsZWdyb3Vwcy5jb20%3D> >> . >> >> [image: Sent from Mailspring] >> >> -- >> 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/FD052ED8-24D7-492D-A0D0-A39A13CBA63A%40getmailspring.com >> <https://groups.google.com/d/msgid/django-users/FD052ED8-24D7-492D-A0D0-A39A13CBA63A%40getmailspring.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/CAPRV45z3%3DS-G9D89-pZhe_kT1qWg8PZeZ%2B8nLHump6DADDVtuw%40mail.gmail.com > <https://groups.google.com/d/msgid/django-users/CAPRV45z3%3DS-G9D89-pZhe_kT1qWg8PZeZ%2B8nLHump6DADDVtuw%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/CAJkmis2rSB81NHei7voOm_rz__mKv5xvn-0dsTLcK911oSxttg%40mail.gmail.com.