1. Django 프로젝트 urls 설정

vi mysite/urls.py

from django.conf.urls import url, include

from django.contrib import admin


urlpatterns = [

  url(r'^admin/', admin.site.urls),

  url(r'', include('demo.urls')),

]

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

]


2. Django 프로젝트 views 설정

vi views.py

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

from __future__ import unicode_literals


from django.shortcuts import render

from django.views import View


# Create your views here.

class demo_base(View):

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

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


3. Django 프로젝트 html 생성

mkdir -p templates/demo

vi templates/demo/demo_base.html

<!doctype html>

<html lang="ko">

<html>

  <head>

    <meta charset="utf-8">

    <title>Django Demo</title>

  </head>


  <body>

    <a href="http://poorman.tistory.com">

      <img src="https://t1.daumcdn.net/cfile/tistory/2368C93A587F63331A"> &nbsp

      Poorman Tistory

    </a>

  </body>


</html>


- 결과

http://~:8080/demo


+ Recent posts