I would like to ask how I can display multiple apps on a main webpage. Now I have a situation that allows me to display only single app. First app in urls file:
我想問一下如何在主網頁上顯示多個應用。現在我的情況允許我只顯示單個應用程序。 url文件中的第一個應用:
(r'^article/',include('articles.urls')),
Second app in urls file:
url文件中的第二個應用:
(r'^section_service/',include('section_service.urls')),
Both apps {% extends "main.html" %}
兩個應用{%extends“main.html”%}
For any advice or examples I will be very grateful.
對於任何建議或例子,我將非常感激。
App "articles" views.py file:
應用“文章”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)})
App "articles" urls.py file
應用“文章”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 file
應用“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 file
應用“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
Only one view can be responsible for rendering any single page. You can of course include content in that view from any app, though.
只有一個視圖可以負責渲染任何單個頁面。當然,您可以從任何應用程序中包含該視圖中的內容。
本站翻译的文章,版权归属于本站,未经许可禁止转摘,转摘请注明本文地址:https://www.itdaan.com/blog/2015/11/24/2fcbd826e451f2d2b0c0f5543593c847.html。