1. 프레임 별의 urls , views 설정

cd demo

vi urls.py

from django.conf.urls import url

from . import views


urlpatterns = [

  url(r'^demo/$',views.demo_base.as_view(), name='demo_base'),

  url(r'^demo/title$',views.demo_title.as_view(), name='demo_title'),

  url(r'^demo/menu$',views.demo_menu.as_view(), name='demo_menu'),

  url(r'^demo/content$',views.demo_content.as_view(), name='demo_content'),

]

vi views.py

# -*- coding: utf-8 -*-

from __future__ import unicode_literals


from django.shortcuts import render

from django.views import View


from .models import *


# Create your views here.

class demo_base(View):

  def get(self, request, *args, **kwargs):

    return render(request, 'demo/demo_base.html', context={})


class demo_title(View):

  def get(self, request, *args, **kwargs):

    return render(request, 'demo/demo_title.html', context={})


class demo_menu(View):

  def get(self, request, *args, **kwargs):

    return render(request, 'demo/demo_menu.html', context={})


class demo_content(View):

  def get(self, request, *args, **kwargs):

    return render(request, 'demo/demo_content.html', context={})


2. 기본 홈페이지의 프레임 나누기

vi templates/demo/demo_base.html

<!doctype html>

<html lang="ko">

<html>

  <head>

    <meta charset="utf-8">

    <title>Demo</title>

  </head>

  <frameset rows="20%,*">

    <frame src="title"/>

      <frameset cols="30%,*">

        <frame src="menu" name="menu"/>

        <frame src="content" name="content"/>

      </frameset>

  </frameset>

</html>


3. 각 프레임에 표시할 내용 설정

vi templates/demo/demo_title.html

<!doctype html>

<html lang="ko">

<html>

  <head>

    <meta charset="utf-8">

    <title>Demo Title</title>

  </head>

  <body>

    <a>Title</a>

  </body>

</html>

vi templates/demo/demo_menu.html

<!doctype html>

<html lang="ko">

<html>

  <head>

    <meta charset="utf-8">

    <title>Demo menu</title>

  </head>

  <body>

    <a>Menu</a>

  </body>

</html>

vi templates/demo/demo_content.html

<!doctype html>

<html lang="ko">

<html>

  <head>

    <meta charset="utf-8">

    <title>Demo Content</title>

  </head>

  <body>

    <a>Content</a>

  </body>

</html>


4. 기본 홈페이지에서 프레임 내용 확인

http://~:8080/demo


+ Recent posts