views.py
def fun(request):
obj=place.objects.all( )
return render(request,"index.html",{'results':obj})
def func(request):
obj=blog.objects.all( )
return render(request,"index.html",{'blogresults':obj})
urls.py:
urlpatterns = [ path('', views.fun, name='fun'),
path('', views.func, name='func')
]
CodePudding user response:
Change second url path to:
path('func/', views.func, name='func')
And you can hit second path via <your_domain>/func/
I would suggest giving meaningful names to your views like:
def place(request):
...
def blog(request):
...
CodePudding user response:
You have the same view function and you try to put both on one page, so you do not need two functions, in this case if you want to show the place and the blog on one page, you can try this:
view.py
def fun(request):
obj_0 = place.objects.all( )
obj_1 = blog.objects.all( )
return render(request,"index.html",{'results':obj_0, 'blogresults': obj_1})
url.py
urlpatterns = [ path('', views.fun, name='fun')]