我想问一下如何在主网页上显示多个应用。现在我的情况允许我只显示单个应用程序。 url文件中的第一个应用程序:
(r'^article/',include('articles.urls')),
网址文件中的第二个应用:
(r'^section_service/',include('section_service.urls')),
两个应用{%extends“main.html”%}
对于任何建议或例子,我将非常感激。
App“articles”views.py文件:
from django.shortcuts import render_to_response
from articles.models import Article
def articles(request):
return render_to_response('articles.html',{'articles' : Article.objects.all()})
def article(request, article_id):
return render_to_response('article.html',{'article': Article.objects.get(id=article_id)})
应用“文章”urls.py文件
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
url(r'^show_all/$', 'articles.views.articles'),
url(r'^(?P<article_id>\d+)/$', 'articles.views.article'),
)
App“section_service”views.py文件
from django.shortcuts import render_to_response
from section_service.models import Section_Service
def section_service(request):
return render_to_response('section_service.html',{'section_service' : Section_Service.objects.all()})
def section_services(request, section_services_id):
return render_to_response('section_services.html',{'section_services': Section_Service.objects.get(id=section_services_id)})
App“section_service”urls.py文件
from django.conf.urls import patterns, include, url
urlpatterns = patterns('',
url(r'^show_all/$', 'section_service.views.section_service'),
url(r'^(?P<section_services_id>\d+)/$', 'section_service.views.section_services'),
)
答案 0 :(得分:0)
只有一个视图可以负责渲染任何单个页面。当然,您可以从任何应用程序中包含该视图中的内容。