更多应用显示在一个网页中

[英]More apps displayed in one webpage


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'),
)

enter image description here

enter image description here

1 个解决方案

#1


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



 
  © 2014-2022 ITdaan.com 联系我们: