Multi return values in single function

28 views
Skip to first unread message

nrupesh08

unread,
Jan 4, 2020, 2:39:52 PM1/4/20
to Django users
hi,
I design cms design on the company profile website.
5 pages on the website:
 index, about, services, projects, contact.

the problem is, 
to display easily DB to frontend expect index page. because. all mixed retrieve DB. just main or sample of the display index page. like., about, service, project and contact. 

like,.: def index(request):
content = {}
return render(request, 'index.html', {})

I want, like return values 
 def index(request):
    content = {
       about, services(4 services displayed), projects(2 project displayed), contact  
    }
     return render(request, 'index.html', {})


but, how to so many return values in one function?

please help me.

Muhammed Rafi A

unread,
Jan 4, 2020, 2:53:38 PM1/4/20
to django...@googlegroups.com
return render(request, 'index.html', content)


--
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/915fc8da-b03f-4404-8007-803e520f68fe%40googlegroups.com.

Eduardo Cervantes

unread,
Jan 4, 2020, 3:33:04 PM1/4/20
to django...@googlegroups.com
I think I understand what you mean but it would be helpful, at least to me, to see some code and possibly a mock up of your intended UI.


N Rupesh

unread,
Jan 4, 2020, 4:02:32 PM1/4/20
to django...@googlegroups.com
I think , you don't understand my problem

Eduardo Cervantes

unread,
Jan 4, 2020, 4:18:59 PM1/4/20
to django...@googlegroups.com
Sorry bud,
Your english is a little rough around the edges so that be part of the barrier.
good luck.


Motaz Hejaze

unread,
Jan 4, 2020, 4:30:27 PM1/4/20
to django...@googlegroups.com
# show us your models.py
def index(request):
    content = {
       about:'about',
       serv1:'serv1',
       serv2:'serv2',
       serv3:'serv3',
       serv4:'serv4',
       project1:'project1',
       project2:'project2',
       contact:'contact',
    }
     return render(request, 'index.html', content)

Evil Kunt

unread,
Jan 4, 2020, 6:33:32 PM1/4/20
to django...@googlegroups.com
Hey ,

content is a dictionary , use key value pair and return it . Use if endif or block in template , to render it accordingly . 

I couldn't get ur question properly , but i can help u , if necessary we can have any webex or skype . 

--
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.

V.K. Vanama

unread,
Jan 4, 2020, 10:13:34 PM1/4/20
to Django users
As per the instructions provided in the Django Documentation 3.0, you are restricted to get or generate only a single return value to each function defined in views.py. Instead, as you stated, the solution to your issue is that creating hyperlinks in which the particular portion of the webpage or website will be redirected to. By specifying explicitly that in your case, "index.html" as the base to all other html files till you decide that your Django Project Creation is Succeeded.
I hope you understand.

I answered your question based on the title and issue posted by you. If you are familiar with my description, its cool. Else, better to upload an image containing the clear picture of communication conversations between the urls which depends on your issue/requirement.

N Rupesh

unread,
Jan 6, 2020, 2:39:23 AM1/6/20
to django...@googlegroups.com
cms.jpg
Reply all
Reply to author
Forward
0 new messages