Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

간단한 블로그를 만들며 Django 이해하기

22,557 views

Published on

파이썬 코리아 2015년 2월 세미나
Django 101 강의 자료

Published in: Software
  • Download or read that Ebooks here ... ......................................................................................................................... DOWNLOAD FULL PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • accessibility Books Library allowing access to top content, including thousands of title from favorite author, plus the ability to read or download a huge selection of books for your pc or smartphone within minutes ,Download or read Ebooks here ... ......................................................................................................................... Download FULL PDF EBOOK here { http://bit.ly/2m6jJ5M }
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Download or read that Ebooks here ... ......................................................................................................................... DOWNLOAD FULL PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • Download or read that Ebooks here ... ......................................................................................................................... DOWNLOAD FULL PDF EBOOK here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download EPUB Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... Download Doc Ebook here { http://bit.ly/2m6jJ5M } ......................................................................................................................... .........................................................................................................................
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here
  • DOWNLOAD THIS BOOKS INTO AVAILABLE FORMAT (Unlimited) ......................................................................................................................... ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download Full EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ACCESS WEBSITE for All Ebooks ......................................................................................................................... Download Full PDF EBOOK here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download EPUB Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... Download doc Ebook here { https://tinyurl.com/yyxo9sk7 } ......................................................................................................................... ......................................................................................................................... ......................................................................................................................... .............. Browse by Genre Available eBooks ......................................................................................................................... Art, Biography, Business, Chick Lit, Children's, Christian, Classics, Comics, Contemporary, Cookbooks, Crime, Ebooks, Fantasy, Fiction, Graphic Novels, Historical Fiction, History, Horror, Humor And Comedy, Manga, Memoir, Music, Mystery, Non Fiction, Paranormal, Philosophy, Poetry, Psychology, Religion, Romance, Science, Science Fiction, Self Help, Suspense, Spirituality, Sports, Thriller, Travel, Young Adult,
       Reply 
    Are you sure you want to  Yes  No
    Your message goes here

간단한 블로그를 만들며 Django 이해하기

  1. 1. 간단한 블로그를 만들며 Django 이해하기 Django 101 - 2015/2/14 Python Korea
  2. 2. 파이 저는 입니다.
  3. 3. Django 알파카코믹스 로 만들었습니다.
  4. 4. https://alpacacomics.com
  5. 5. Django를 배우기 전에
  6. 6. HTTP 요청과 응답을
  7. 7. 이해해봅시다.
  8. 8. 식당에 갑니다.
  9. 9. 스테이크를 주문합니다.
  10. 10. 주방에서 음식을 만듭니다.
  11. 11. 손님에게 내놓습니다.
  12. 12. 식당에서 스테이크 1인분이요!
  13. 13. HTTP https://alpacacomics.com
  14. 14. HTTP https://alpacacomics.com Server HTML CSS JS ...
  15. 15. https://alpacacomics.com HTTP Request Response
  16. 16. 대충 설명하면 이렇습니다.
  17. 17. 주문 / 음식 URL* / HTML* Request / Response
  18. 18. 이 모든 것은
  19. 19. ‘문서’로 되어있습니다.
  20. 20. https://alpacacomics.com HTTP Request Response
  21. 21. Request ‘문서’
  22. 22. https://alpacacomics.com HTTP Request Response
  23. 23. Response ‘문서’
  24. 24. 인터넷 브라우저는
  25. 25. Request 문서를 만들어서 보내고
  26. 26. Response 문서를 받습니다.
  27. 27. 그리고 예쁘게 보여줍니다.
  28. 28. 서버는
  29. 29. Request 문서를 해석하고
  30. 30. Response 문서를 만들어 줍니다.
  31. 31. Django는
  32. 32. Request를 해석하고
  33. 33. Response를 만듭니다.
  34. 34. Django는 어디에? https://alpacacomics.com Server HTML CSS JS ... Django
  35. 35. Server를 확대하면
  36. 36. VIEW Server urls.py … MODEL TEMPLATE Data Base Web Server
  37. 37. VIEW Server urls.py … MODEL TEMPLATE Data Base Web Server Django
  38. 38. Django가 하는 일
  39. 39. Application server
  40. 40. 다른 건 못해요.
  41. 41. VIEW 쓸모 있는 친구들 urls.py … MODEL TEMPLATE Data Base Web Server uWSGI Nginx MySQL manage.py runserver
  42. 42. Django만 확대하면
  43. 43. views.py Django urls.py models.py templates/ ...html Middle ware* settings.py
  44. 44. 대충 흐름만 보세요.
  45. 45. Django 홈페이지 보세요. 제대로 된 내용이 궁금하시면?! http://www.djangoproject.com
  46. 46. 간단한 블로그를 만들면서
  47. 47. 이 흐름을 알아봅시다.
  48. 48. 우리가 만들 블로그 어떤 블로그를 만들 것인가? 터..텀블러?
  49. 49. 글 목록 보기 / 그냥 다 뿌립니다.
  50. 50. 글 내용 보기 /{ 글 번호 }/ 없으면 허전하죠.
  51. 51. 글 쓰기 /create/ 쓰긴 해야...
  52. 52. 분류된 글 목록 /?category={ 분류 번호 } 필터 생색 내봅니다.
  53. 53. 단순합니다.
  54. 54. 모델도 설계해봅니다.
  55. 55. name Category 더 할게 없네
  56. 56. category title content Post created 는 덤으로
  57. 57. 별거 없습니다.
  58. 58. 이제 만들어봅시다.
  59. 59. 실습 프로젝트 https://github.com/perhapsspy/pylog/commits/master 보면서 합시다.
  60. 60. Python 2.7.x 설치되어 있으시겠죠? 어..없으면 곤란합니다.
  61. 61. pip install virtualenvwapper mkvirtualenv pylog workon pylog deactivate Python 가상 환경 만들기 https://virtualenvwrapper.readthedocs.org/en/latest/
  62. 62. pip install django Django 설치 https://docs.djangoproject.com/en/1.7/intro/install/
  63. 63. django-admin startproject pylog Django 프로젝트 생성 https://docs.djangoproject.com/en/1.7/intro/tutorial01/#creating-a-project
  64. 64. cd pylog django-admin startapp blog python manage.py runserver ctrl + c blog 앱 생성 http://127.0.0.1:8000/
  65. 65. pylog/blog/models.py # -*- coding: utf-8 -*- from django.db import models class Category(models.Model): class Meta: verbose_name = u'분류' ordering = ['name'] name = models.CharField(verbose_name=u'이름', max_length=50) def __unicode__(self): return self.name class Post(models.Model): class Meta: verbose_name = u'글' ordering = ['created'] category = models.ForeignKey(Category, verbose_name=u'분류', null=True, blank=True) title = models.CharField(verbose_name=u'제목', max_length=256) content = models.TextField(u'내용', blank=True, default='') created = models.DateTimeField(auto_now_add=True, verbose_name=u'생성일') def __unicode__(self): return self.title
  66. 66. pylog/blog/admin.py from django.contrib import admin from blog.models import Category, Post class CategoryAdmin(admin.ModelAdmin): list_display = ['id', 'name'] list_editable = ['name'] search_fields = ['name'] ordering = ['name'] class PostAdmin(admin.ModelAdmin): list_display = ['id', 'title', 'created'] list_filter = ['category'] list_display_links = ['id', 'title'] search_fields = ['title', 'content', ] ordering = ['-created'] admin.site.register(Category, CategoryAdmin) admin.site.register(Post, PostAdmin)
  67. 67. python manage.py makemigrations blog python manage.py migrate python manage.py createsuperuser python manage.py runserver Database Migration http://127.0.0.1:8000/admin/
  68. 68. Category와 Post를 적당히 입력해봅시다. admin 페이지에서
  69. 69. Post admin에 Category 추가 class PostAdmin(admin.ModelAdmin): - list_display = ['id', 'title', 'created'] + list_display = ['id','category', 'title', 'created'] list_filter = ['category'] + list_editable = ['category'] list_display_links = ['id', 'title'] search_fields = ['title', 'content', ] ordering = ['-created'] pylog/blog/admin.py
  70. 70. 진행합니다. 이제부터는 github commit을 보면서 소스 넣기 힘들어요… 설명도 강의하면서...
  71. 71. home view hi https://github.com/perhapsspy/pylog/commit/06c31a3 7649d8cc52a2199886b67be3acf49f885
  72. 72. 기본 template 적용 https://github.com/perhapsspy/pylog/commit/ba2543 addd36bf5717d62d31e35c8376b23f8e57
  73. 73. template 상속으로 home 구현 https://github.com/perhapsspy/pylog/commit/fe9827f 4486ed73fa5fc0c8ca67325fcf3b5d9a7
  74. 74. home에서 글 목록 보여주기 https://github.com/perhapsspy/pylog/commit/0c00fb1 90b48dcbe7a916666ef3d77a3c1a727b0
  75. 75. 글 내용 보기 만들기 https://github.com/perhapsspy/pylog/commit/148b4d e0f7d166933bf3e9d327d4d7195a40cbaa
  76. 76. FBV를 CBV로 바꾸기 https://github.com/perhapsspy/pylog/commit/22595a a6df9589b74a5764722f71d599bd372438
  77. 77. 글쓰기 기능 추가 https://github.com/perhapsspy/pylog/commit/d9b035 67d57be664b976550567825435cb56d4ec
  78. 78. 글 목록에서 분류 표시 https://github.com/perhapsspy/pylog/commit/2f38bbd 60055029022abff4c4cd1e3a0d9028095
  79. 79. 분류 기능 추가 https://github.com/perhapsspy/pylog/commit/713e03 d43828d3301ae6b266e59638c6ee42b4a3
  80. 80. 테스트 케이스 작성 https://github.com/perhapsspy/pylog/commit/1b4871 15c9f6602a7a65464096ef11512f3d520f
  81. 81. 수고하셨습니다.

×