From 7807c98459aa34b25c1a214995a305cc932db3b0 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Sat, 4 Jul 2020 01:07:35 +0900 Subject: [PATCH 1/2] Learning Circle : django #1, #2 - Tutorial01, Tutorial02 --- youngjin.han/django/.gitignore | 1 + youngjin.han/django/django.org | 13 ++ youngjin.han/django/mysite/db.sqlite3 | Bin 0 -> 143360 bytes youngjin.han/django/mysite/manage.py | 22 ++++ youngjin.han/django/mysite/mysite/__init__.py | 0 .../django/mysite/mysite/__init__.pyc | Bin 0 -> 173 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 0 -> 173 bytes .../__pycache__/settings.cpython-37.pyc | Bin 0 -> 2325 bytes .../mysite/__pycache__/urls.cpython-37.pyc | Bin 0 -> 1009 bytes .../mysite/__pycache__/wsgi.cpython-37.pyc | Bin 0 -> 575 bytes youngjin.han/django/mysite/mysite/settings.py | 123 ++++++++++++++++++ .../django/mysite/mysite/settings.pyc | Bin 0 -> 2629 bytes youngjin.han/django/mysite/mysite/urls.py | 31 +++++ youngjin.han/django/mysite/mysite/urls.pyc | Bin 0 -> 1080 bytes youngjin.han/django/mysite/mysite/wsgi.py | 16 +++ youngjin.han/django/mysite/polls/__init__.py | 0 youngjin.han/django/mysite/polls/__init__.pyc | Bin 0 -> 167 bytes .../polls/__pycache__/__init__.cpython-37.pyc | Bin 0 -> 172 bytes .../polls/__pycache__/admin.cpython-37.pyc | Bin 0 -> 259 bytes .../polls/__pycache__/apps.cpython-37.pyc | Bin 0 -> 437 bytes .../polls/__pycache__/models.cpython-37.pyc | Bin 0 -> 1344 bytes .../polls/__pycache__/urls.cpython-37.pyc | Bin 0 -> 301 bytes .../polls/__pycache__/views.cpython-37.pyc | Bin 0 -> 465 bytes youngjin.han/django/mysite/polls/admin.py | 6 + youngjin.han/django/mysite/polls/admin.pyc | Bin 0 -> 288 bytes youngjin.han/django/mysite/polls/apps.py | 8 ++ youngjin.han/django/mysite/polls/apps.pyc | Bin 0 -> 538 bytes .../mysite/polls/migrations/0001_initial.py | 32 +++++ .../mysite/polls/migrations/__init__.py | 0 .../__pycache__/0001_initial.cpython-37.pyc | Bin 0 -> 1017 bytes .../__pycache__/__init__.cpython-37.pyc | Bin 0 -> 178 bytes youngjin.han/django/mysite/polls/models.py | 26 ++++ youngjin.han/django/mysite/polls/models.pyc | Bin 0 -> 1824 bytes youngjin.han/django/mysite/polls/tests.py | 6 + youngjin.han/django/mysite/polls/urls.py | 7 + youngjin.han/django/mysite/polls/views.py | 11 ++ youngjin.han/learning-node02-2020.org | 36 +++++ 37 files changed, 338 insertions(+) create mode 100644 youngjin.han/django/.gitignore create mode 100644 youngjin.han/django/django.org create mode 100644 youngjin.han/django/mysite/db.sqlite3 create mode 100755 youngjin.han/django/mysite/manage.py create mode 100644 youngjin.han/django/mysite/mysite/__init__.py create mode 100644 youngjin.han/django/mysite/mysite/__init__.pyc create mode 100644 youngjin.han/django/mysite/mysite/__pycache__/__init__.cpython-37.pyc create mode 100644 youngjin.han/django/mysite/mysite/__pycache__/settings.cpython-37.pyc create mode 100644 youngjin.han/django/mysite/mysite/__pycache__/urls.cpython-37.pyc create mode 100644 youngjin.han/django/mysite/mysite/__pycache__/wsgi.cpython-37.pyc create mode 100644 youngjin.han/django/mysite/mysite/settings.py create mode 100644 youngjin.han/django/mysite/mysite/settings.pyc create mode 100644 youngjin.han/django/mysite/mysite/urls.py create mode 100644 youngjin.han/django/mysite/mysite/urls.pyc create mode 100644 youngjin.han/django/mysite/mysite/wsgi.py create mode 100644 youngjin.han/django/mysite/polls/__init__.py create mode 100644 youngjin.han/django/mysite/polls/__init__.pyc create mode 100644 youngjin.han/django/mysite/polls/__pycache__/__init__.cpython-37.pyc create mode 100644 youngjin.han/django/mysite/polls/__pycache__/admin.cpython-37.pyc create mode 100644 youngjin.han/django/mysite/polls/__pycache__/apps.cpython-37.pyc create mode 100644 youngjin.han/django/mysite/polls/__pycache__/models.cpython-37.pyc create mode 100644 youngjin.han/django/mysite/polls/__pycache__/urls.cpython-37.pyc create mode 100644 youngjin.han/django/mysite/polls/__pycache__/views.cpython-37.pyc create mode 100644 youngjin.han/django/mysite/polls/admin.py create mode 100644 youngjin.han/django/mysite/polls/admin.pyc create mode 100644 youngjin.han/django/mysite/polls/apps.py create mode 100644 youngjin.han/django/mysite/polls/apps.pyc create mode 100644 youngjin.han/django/mysite/polls/migrations/0001_initial.py create mode 100644 youngjin.han/django/mysite/polls/migrations/__init__.py create mode 100644 youngjin.han/django/mysite/polls/migrations/__pycache__/0001_initial.cpython-37.pyc create mode 100644 youngjin.han/django/mysite/polls/migrations/__pycache__/__init__.cpython-37.pyc create mode 100644 youngjin.han/django/mysite/polls/models.py create mode 100644 youngjin.han/django/mysite/polls/models.pyc create mode 100644 youngjin.han/django/mysite/polls/tests.py create mode 100644 youngjin.han/django/mysite/polls/urls.py create mode 100644 youngjin.han/django/mysite/polls/views.py diff --git a/youngjin.han/django/.gitignore b/youngjin.han/django/.gitignore new file mode 100644 index 0000000..09dd1da --- /dev/null +++ b/youngjin.han/django/.gitignore @@ -0,0 +1 @@ +venv/* diff --git a/youngjin.han/django/django.org b/youngjin.han/django/django.org new file mode 100644 index 0000000..2b11edd --- /dev/null +++ b/youngjin.han/django/django.org @@ -0,0 +1,13 @@ +* 2020-07-04 +** note + - none +* 2020-06-28 +** note + - Research and answer the following questions: (1/2 of the time) + - What is IPv6 ULA? + : unique local address + : prefix is fc00::/7 + - Which registries did exist historically? + : RIR, LIR, NIR, AFRINIC, APNIC, ARIN, LACNIC, RIPE NCC + - How should an IPv6 ULA registry work? + :I do not have a idea. diff --git a/youngjin.han/django/mysite/db.sqlite3 b/youngjin.han/django/mysite/db.sqlite3 new file mode 100644 index 0000000000000000000000000000000000000000..059e514a489eb744fdaa0cf81c053c2021175250 GIT binary patch literal 143360 zcmeI5dyE^$eaCl?Zym|GhfcICoo?@>vqYRvw_LuCvR(TupJi3@$&#fgGGc6(+6EsaUCEIp$r zk|Z6Ye~;3?_Ui@u#&2KHe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-pgP{~rC2LbX5u1V8`;KmY_l00ck)1V8`;K)^)+^M4l%yafRe z009sH0T2KI5C8!X009sHfjvrqo&T4~w^Xam96H}nyRUbYJO2oD=F<%I(sUcJ*j1KY9Yhs|0CqP68R7EUGnvh zR3#x61V8`;KmY_l00ck)1V8`;KmY{(e-b!2wAxYng#m}ck;|K=(thnujD9J=bU3os z=qR613g%>j{pDw literal 0 HcmV?d00001 diff --git a/youngjin.han/django/mysite/manage.py b/youngjin.han/django/mysite/manage.py new file mode 100755 index 0000000..afbc784 --- /dev/null +++ b/youngjin.han/django/mysite/manage.py @@ -0,0 +1,22 @@ +#!/usr/bin/env python +import os +import sys + +if __name__ == "__main__": + os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") + try: + from django.core.management import execute_from_command_line + except ImportError: + # The above import may fail for some other reason. Ensure that the + # issue is really that Django is missing to avoid masking other + # exceptions on Python 2. + try: + import django + except ImportError: + raise ImportError( + "Couldn't import Django. Are you sure it's installed and " + "available on your PYTHONPATH environment variable? Did you " + "forget to activate a virtual environment?" + ) + raise + execute_from_command_line(sys.argv) diff --git a/youngjin.han/django/mysite/mysite/__init__.py b/youngjin.han/django/mysite/mysite/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/youngjin.han/django/mysite/mysite/__init__.pyc b/youngjin.han/django/mysite/mysite/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..49b363aaaf07bcb44e5fe419c6788da453199883 GIT binary patch literal 173 zcmZSn%*)lT^gk|{0SXv_v;zg`kf_A0-qN-jYF literal 0 HcmV?d00001 diff --git a/youngjin.han/django/mysite/mysite/__pycache__/settings.cpython-37.pyc b/youngjin.han/django/mysite/mysite/__pycache__/settings.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e60958a6557621a73f7025baa8a06a4e513591f6 GIT binary patch literal 2325 zcmb7FTXWk)6!t~29p}SGKhbhA!+R@+CZOz`2RI%DOT+8DrW{kKN<-4BGJ3~qs<_Esl$0ies#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5LM356Z1w60IxfE%l)8Z0-^9(? znB5E-UGhG8P!E?&XrtwF@$fHbXT-IEo<{XS`{viN`>jT)k*8Yl& zpSouIbwPZY$%d{psnojQBFm@H$wmRY(@dDG;AE%a*G8x`r;6-@ku6tSvY)5!@R8DT ZSC5`c&8mXGcm!eW2(~Cb3?BCmgFk4QJsSW3 literal 0 HcmV?d00001 diff --git a/youngjin.han/django/mysite/mysite/__pycache__/wsgi.cpython-37.pyc b/youngjin.han/django/mysite/mysite/__pycache__/wsgi.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..7e24142c3d6c631712e0eadffb23dacf01044500 GIT binary patch literal 575 zcmYk3&5qMB5XT+2yR8BX91v%VTO~H8SA-CtU8*AJN^}uY52PlZB#s_ufu{9fHHZjA)$sd~9Ll2~6nBF!WOXd*l1z@Tf5jh`vpLJG$yLE}>sY<>DgbMo ztso0Y9M1!T&yDrqStx<^_l4HtlLjU{6Rfs!qv2G;7Bt%mr}iNuYLINb7EPm7CW5kN zy~cd6I*4_^ltEs-4=`&mx$-Pm8XhqZ5SJk|{t4&OWD!C5_ixUx z@Akh>JcOW3;U}YZl%^;lOKb_8atoHcEX4<+PcqeFY^2Jk0w zT@Ux}?>iJ-1FuAG`Nk9)R90f~gfoad&6LYD@SVj_rA$%^!+R>CgyUBpw_)jU3YI1FEb$+h_D*bSF~t zm0!}|*dIXmPL}OXJkyCKpZ0F|d3JBLdn*02R{8t>=eIsge#`jW!9U+C01yBN#{!Td z1O;#kKnpM|!mxBoSOR(uJ{2anQwCB3XBp@UIIGY{o(hm9Am@OfY8l81kX0ZR=r4nF z9thqSfUE)e0?0)mmw;SWDqOq*&KfYpUInraRpcVqpo+xgI#e0Pb_2*wAh&?rhCZ6z zfhzeD?J!;>y9>@mKr2=R@)eM;5t(h_5>SjpgHNc~K*%>xbuLRwa!)Nt>HbuDFqOVl z5;}6O0C@-wMzsmfy4vYAHC|UEM)e3B46F$D=3|*r12bBw551@#Yn%$fqCVGpaiWD| z&IHv)Nj#*!&?}W)8qvfPlxW?t_K+yZmPbMsXm4QjR3rgmYWp-qxS~g!osI zG)}0-BIFM}!Qx26TMQU_WC8si1E7_G5F`GxVUXD8dgdjM!H+|OMuwy`L_A_XH}a5; zj9(0>)=Psx3m6w#+?#F5iwJt6EYUuAK}z|VoF%k3=ZSsBUyDD*^ob`Qd)vOdQDqxx z@GR*Mb{<7z;yz)|hYvmkAHoeD4924GzU4a~N7Z{L8xQz(gpJ}L;JP;&as5DwwK(dr zK3_*wwqxCoBayJKuJX&TE>NUm!0()1mp~c`F&o0tHcXwdn6l#&q2>4H0w$|O#;r18I_>nD8Sy-yU0N!l6Q`tbzx_s z=0cvNFU{I(t5p|EDAyZ@wpc;IJUDRWgl{fjRYmoeaIq16+)bXAuk2ut}r77|bYsJp)D7 zVF!~)XB<0c;Ao{GO_+b0Le)@GLpLW z@@QAAp=36j?PII%?zQcXExy2&M$7KtDz0Ih*otPqQLi_xWAo4w7trFc-R`(Yhs|2M z^-8SbLdV)aXqp|%7ME~#Z0|NCw%Mqevi_9oVay_BTQ@tVjL{Z1(bhcb?70V~Z6CJ} z>+Tz~*+6|8+f>HZG+Vnz=C0+|+I1^))Y!LNr`@vDR*!I}jqM*>(@AstNlR6%)O4II z1sx2cCd1uCN|+7&H=G)SIHbnV>%~SI^#jWM!B#-MB*L?4%V&unP-7gUYRDpe;6+AO z+(y<-`6K@@>!Y!X<(DufX+U4dLyZ54L%DdN^mw^kDi_P;Qn6IXuhpeolF!vrxl}4F bt1Gu!FCzkV%Z0nEI3hOxudN_kc9s7Hu0sW7 literal 0 HcmV?d00001 diff --git a/youngjin.han/django/mysite/mysite/urls.py b/youngjin.han/django/mysite/mysite/urls.py new file mode 100644 index 0000000..7ae405d --- /dev/null +++ b/youngjin.han/django/mysite/mysite/urls.py @@ -0,0 +1,31 @@ +"""mysite URL Configuration + +The `urlpatterns` list routes URLs to views. For more information please see: + https://docs.djangoproject.com/en/1.11/topics/http/urls/ +Examples: +Function views + 1. Add an import: from my_app import views + 2. Add a URL to urlpatterns: url(r'^$', views.home, name='home') +Class-based views + 1. Add an import: from other_app.views import Home + 2. Add a URL to urlpatterns: url(r'^$', Home.as_view(), name='home') +Including another URLconf + 1. Import the include() function: from django.conf.urls import url, include + 2. Add a URL to urlpatterns: url(r'^blog/', include('blog.urls')) +""" +""" +from django.conf.urls import url +from django.contrib import admin + +urlpatterns = [ + url(r'^admin/', admin.site.urls), +] +""" + +from django.contrib import admin +from django.urls import include, path + +urlpatterns = [ + path('polls/', include('polls.urls')), + path('admin/', admin.site.urls), + ] diff --git a/youngjin.han/django/mysite/mysite/urls.pyc b/youngjin.han/django/mysite/mysite/urls.pyc new file mode 100644 index 0000000000000000000000000000000000000000..2aa9842bdd65054da17516077270332a4e14ebe9 GIT binary patch literal 1080 zcma)5OK%e~5T4DeWf2c?;A{z`Y@~LraEt(fDk>@=4goGXG~KS9tfRHPvb}+v`_(DL1wuQ4}q5BGmOY^bCoDtW9`N9Z$RMg9-w zLmqkImjshd{^4|C%DNTGtg#R=BBfViN4pwb#Nsd{gFPZ!nN8U0P|n%DWc!|AGt4Td z%6D8*KIyz3&iT5wYmRm7!i`B0amSNMs%~**3C>{{;#LT)Oojsq;Rv^bPoVdJ16cVH z3AV;*@M$MTtauZ>`Pb|bUPb@q5{GQL3{O#UmsN1;dX5?hkMH!9=$v@WV|0p0Pa=k< zyJ(9-_YN{NfV<5TAg9UTn_^{oYu2??Wp#?f?+iBNv{bIFCEr=R+9;D(h2eWnd@IeC i@1J0IP{_R51$v=xwH0kG-#S( literal 0 HcmV?d00001 diff --git a/youngjin.han/django/mysite/mysite/wsgi.py b/youngjin.han/django/mysite/mysite/wsgi.py new file mode 100644 index 0000000..74e7dae --- /dev/null +++ b/youngjin.han/django/mysite/mysite/wsgi.py @@ -0,0 +1,16 @@ +""" +WSGI config for mysite project. + +It exposes the WSGI callable as a module-level variable named ``application``. + +For more information on this file, see +https://docs.djangoproject.com/en/1.11/howto/deployment/wsgi/ +""" + +import os + +from django.core.wsgi import get_wsgi_application + +os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings") + +application = get_wsgi_application() diff --git a/youngjin.han/django/mysite/polls/__init__.py b/youngjin.han/django/mysite/polls/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/youngjin.han/django/mysite/polls/__init__.pyc b/youngjin.han/django/mysite/polls/__init__.pyc new file mode 100644 index 0000000000000000000000000000000000000000..a6c1773347f4227d173d7167274a83174f68473f GIT binary patch literal 167 zcmZSn%*(Y?>3>`@0~9aG}G(mBpDQsrm)^ lIXT7p@$s2?nI-Y@dIgmw96&>Da`RJ4b5iXg`kf}KkL<3RLd5CH>>K!yVl7qb9~6oz01O-8?!3`HPe1o10WKO;XkRX-~+ zEnmMhFFhwUGdV*yCpEDsFEcM)H#xH?IVV-WG9M_Fm6@lPk(j5Sl9ia3p08h)npdWu sTUnf0lB!>jpOaIpA0MBYmst`YuUAlci^C>2KczG$)edCcXCP((0Jt130RR91 literal 0 HcmV?d00001 diff --git a/youngjin.han/django/mysite/polls/__pycache__/admin.cpython-37.pyc b/youngjin.han/django/mysite/polls/__pycache__/admin.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c4feb4fe80336652da8763782de7bf15466a7cd7 GIT binary patch literal 259 zcmXv|J5Izf5VezC39VSf0jTIwYibX`k6JWFWO)Y zUv4ux9gLOWCL0wb>aCUW4xgIUvXSzXryQ-6v6y!^W>naRRtKD-dyO?U-&tG}UEups z48dD5s#6ddd$3LqJFqIE!+xh-)L_LNXf!%(2ZiF#QTRF02jUz6lDIt3p6BIi?}N!; LAIkMq;JW$+32;Vk literal 0 HcmV?d00001 diff --git a/youngjin.han/django/mysite/polls/__pycache__/apps.cpython-37.pyc b/youngjin.han/django/mysite/polls/__pycache__/apps.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..ad851ae9018f367f6b19b7e334c0c21907315f41 GIT binary patch literal 437 zcmYLGOHRWu5VhkJ(x22bu!}_N3m{Zr!L9;z=LMD(yQwS34t7(iYd8aU;0RnLTUK0w z4U7{iMw*#7o{!(yx6|nefqY#2JiUScjKN7#087wt2}UA`4XQB1IO4=46=4LUdnAcW zUy)1|c_A#7gEh*}zMuo;xScgt7fvc}^j>*k0-OzR>iW*vjV_B=brK9<2^wZ#6k=E+ zmPpKqOkg5u#}Ce!&^NL{9fMV#wi)MEREqO<#ChdpVF7b(1Fen$)}b8-D(X5c z>Z6aZbsqUAU^3jrt9-zK)~4Av9%%WPYRCPkMQrp0PP)>6ay^RQ(q>ovM%S@1#2Y5b Gg!}?$&23fy literal 0 HcmV?d00001 diff --git a/youngjin.han/django/mysite/polls/__pycache__/models.cpython-37.pyc b/youngjin.han/django/mysite/polls/__pycache__/models.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..b59588a08095b5fd1cae257fcb8f5df97e9e69b9 GIT binary patch literal 1344 zcmZ`(O>fjN5Vey{;%u`}$~QuS8`?v=66XpETR;f05`t3>m=L?WS)8P`9m-bR;L3j} zNB#-FAy-cQ1xQ?ACdsY}DwaH%JbTB_Z(jD{V9+Np?%(a*R8~|k|kTRR)@~A9iiu;$tg=7b&xeGy(mbWMPJ0 z%|Ho`l4$fu?H1)>&F~$2Q->I#T{am~9m0m@!fjZ?{Z|eX!&hQ*EmK)owb+2QCG%S= z=4bDn4Er_Xyhw7%dEMt6gs2qe5$6Y0qS_UWzNo|TEYXiMsf1?uKG+4SuYhEWod--u z7%pPK?wkt9Sff+}mE|lQExi9D!Ck`NE!VxaGGK9R3 zeuR9j^JCQc(I3ysER~>oSQZ@Qlpr@+3`7m!p}U?0LhdD%vVXPqzn)x6o2s27&+1O2 z#C14e*@|;5k)?$u!-2kp=U>Kf1w$ip|8c2hHZ7jXMI%fdj32xlKiGW~v*mZ7uj1~T z5bEe@VdYe|U8%kIrIn`b!CCSn9Xzg+e;pbSQH?0r0Ghv7*-At6HTu2|+Ye<+ylt52 v3kXIXSlLXO*0$br{8MSjHnmPQy&=(fm2J1qx`(9=x+HQUmpQ<|-C%zJ5lc3O literal 0 HcmV?d00001 diff --git a/youngjin.han/django/mysite/polls/__pycache__/urls.cpython-37.pyc b/youngjin.han/django/mysite/polls/__pycache__/urls.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..d00d0858191899700c0d0723ce2eb288fb4b0f65 GIT binary patch literal 301 zcmXv|OHRZv3{9H0jF_2IuC2gTw_8bI>6J^V4uD}Ky zMp*K*t!MkayZ!!}V0_;EJiTH4O2dB?*qks!jUb7nni$$pN@OOP&J1f9B|v2kY{+FH z%Xik%rjS>Uq}rVEhEz1>qnP?Ly$r>o;3Y&73uPs|CfW)E_f;9UauBw2_3U-<8Ls;z z@ACvDLfj&Qzb5cDd=Q^(|H1bI@0|fYh-b%V+i6g3f6ySjRkk~{%C{Q$>W~_gt$Shl lMT#$A7jD*|Cg7vfI`AZ3k89lA8YgEB$K*RC54&u~egT@wPmurs literal 0 HcmV?d00001 diff --git a/youngjin.han/django/mysite/polls/__pycache__/views.cpython-37.pyc b/youngjin.han/django/mysite/polls/__pycache__/views.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..e1f4a9ebc64812d7a815c19f1d8808da04fc7890 GIT binary patch literal 465 zcmYjNOHRWu5Veygtx7BP2oW2oL}Lzs5Q0rtU6d7B5JmB{N#)qZpO&(P%W$QL9V@QD z2F3v-M)LT1#`E5@ugBvd!FW6Vx(_KK@BZ)?0fH-B<{T3zoC?y=j8cyS5j0_jBZx!M zYoaVd+~d&;$zmSgl4<_~r^uAH6DR9ZamYn&K^MYcE!H48XhfsAwc90_t&#>xw9tj$ zz5ER>Gr(j~{+S|euy{J1gAnR0*()u0n%pUOq9G}4Vk=0tN(htG$o`m4sqWz{s`NEH zI575==ol-XOIE1{*rr%1=HyyHT~;#zg_gBk&&pbt0@y)eYg5a#DkS5ZLar6tf!wj? zVDKrdlVZCX_9opP+Ncxt-)X#cLbW%(nD*OYp0AvB8uDEGRyO%zOHHM;EuA$w#BzJ| iTdwd+I_Dij=lEah`>TVCMsX+L((@Vrrcp2oN8vZUs&&!; literal 0 HcmV?d00001 diff --git a/youngjin.han/django/mysite/polls/admin.py b/youngjin.han/django/mysite/polls/admin.py new file mode 100644 index 0000000..13be29d --- /dev/null +++ b/youngjin.han/django/mysite/polls/admin.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.contrib import admin + +# Register your models here. diff --git a/youngjin.han/django/mysite/polls/admin.pyc b/youngjin.han/django/mysite/polls/admin.pyc new file mode 100644 index 0000000000000000000000000000000000000000..03cda8a00f440007d07600656fa7700c283cbd53 GIT binary patch literal 288 zcmYL_O=<%%425M+3MJ5zGn6i7lko*g=>?iay33-*wVfFcvK{=hn4|SvJwPfafe7=g zk0(EbyT7OP@5}jH!>u^oAHX5MQe)^aKmgC+z<@R8fE;`WhmN>|uYN^??o8D)>dJKH{0BU-1YEn1a=3*%P1q|u5ck~O<9Oe%&lVw+uE>JON}SY{V@Gka$Qmxixi~G0n_|Mhq`{wXb!trptA0PsMi=x7hfdOb4kx1D=GT8rB#_t4mj@!stQu()c-Zftkmydv>}Bo5Xd9z+x!V{ed#i1;DRo~OB_@Zdy|(F2T2bw#ZJcN)k5h?2AY|A1w41UB8=m3s xNi5lGLXbzAdK|_cX)=6*F!tOjrQ(dn4do}ip#GgPEb4Av%{^gy+Ri#!^IuC0ep~gOr1>C=@z#0 z4Q%00_y%uT^%vN{buvSRgd^YFW5?(E96N6YgRVjC>$BeO7^Lj-zcErGcbG(%r|4hx3HD8frE*i#0Ex>1ubYVtqTqv8gsw~XUPb433Z_d zeT`xh21{PA9sYOi#y@K}3H4wLwri$)g!(v0hDj&cNH$>y?k_oUTADNF{uVqSeGip$ zvKDr(><@D+wMNAS94UT$=vt~D&Z{DbB!(4&>dmCcLb(V&;X*kjN)e{w237wG<)kPv z$iocP;BrM2RCrz8{vbHPXZvyo1uP7XtCRVMhqQX+LhQ9-N5zf;}+3WH*!&#B0WExaBvthRXP5)#k)Xny3aj3@_U1%i3Tf&Q z=YT9b()(7K`^R~OF|H=NM}t7p2sPQXu6wXD07j=yOEGlir%82sYK+X zX_$LW9WPsyqC&5>%DcPg-rnBci(n;uG+RjhBXy{kk15#P;+ADG&Ue_5?U?Iq$m;Lh xwsIQ!5lm{I8fzZ?9UL`((P%ADKGjNejXOd*V^Gyf40eN^A7|LDf0jT literal 0 HcmV?d00001 diff --git a/youngjin.han/django/mysite/polls/migrations/__pycache__/__init__.cpython-37.pyc b/youngjin.han/django/mysite/polls/migrations/__pycache__/__init__.cpython-37.pyc new file mode 100644 index 0000000000000000000000000000000000000000..dc491d7e99579a283f0a82ab6d808b4229bdb30d GIT binary patch literal 178 zcmZ?b<>g`kf}KkL<3RLd5CH>>K!yVl7qb9~6oz01O-8?!3`HPe1o10cKO;XkRX-~+ zEnmMhFFhwUGdV*yCpEDsFEcM)H#xH?IVV-WG9M_Fm6@lPk(j5Sl9ia3p0A%= timezone.now() - datetime.timedelta(days=1) + +class Choice(models.Model): + question = models.ForeignKey(Question, on_delete=models.CASCADE) + choice_text = models.CharField(max_length=200) + votes = models.IntegerField(default=0) + def __str__(self): + return self.choice_text diff --git a/youngjin.han/django/mysite/polls/models.pyc b/youngjin.han/django/mysite/polls/models.pyc new file mode 100644 index 0000000000000000000000000000000000000000..c3c7fd53ad666503af8beac6cb26ec4039351c76 GIT binary patch literal 1824 zcmcgs&2G~`5T3R3*B@w93Dn+@IFL*02LJ&jr4mA|gv*5-Sh@Bj*|1(0@0vD<6XD@_ zA0D90tev!Q;1;Z8Jv+0>%=gVV8~(bt`QpjV#}t|;r1wh*zbb6pMDUC9dgH)BN#%NwpXr|2JG%-;&OU$H*^0_4zqsu~T8`bn3 zUd|oYB&Btwl+3sdXaTXRo$>nGACpnn?gY$;BjSOYOlqJe^H%JAY7?%I&Yd}~JxeGf z!>mc;z7RK(Ns2iO{T#p)SH5HH84FWlf`0{EVA)ow-^GxagYZo#dq z%`tP$sVujlBX-4(*a#dmJDe6O#gr`naOeD_oRV>OQqT{6JtGStXh7Je=~(uk2An;9 znrUQsrZ$1@0v@6*o*mBS=_!n)_9E$kv-$b)I?QmKRN5(W!b*Wm>c6IEiw}DYx3jZ; z$@u2&Q|hHSw#kn95{P$r@lxP>;-n~1P0U-I`yP0l!=v-z(eZ1qrRCtqJbm#4S{(n? z8{=?-wTK*x=u6?y`mFy!Ev$MjrBTZs>19_87)~SkapkI#B~Pxpr}Zs!m|b}2F?YoS tY5bK_+SX&wXioY1_JqWoYyFTs*U#!nea^R!WtRIvKim%bq95+}egpO)liUCR literal 0 HcmV?d00001 diff --git a/youngjin.han/django/mysite/polls/tests.py b/youngjin.han/django/mysite/polls/tests.py new file mode 100644 index 0000000..5982e6b --- /dev/null +++ b/youngjin.han/django/mysite/polls/tests.py @@ -0,0 +1,6 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.test import TestCase + +# Create your tests here. diff --git a/youngjin.han/django/mysite/polls/urls.py b/youngjin.han/django/mysite/polls/urls.py new file mode 100644 index 0000000..ee00c7d --- /dev/null +++ b/youngjin.han/django/mysite/polls/urls.py @@ -0,0 +1,7 @@ +from django.urls import path + +from . import views + +urlpatterns = [ + path('', views.index, name='index'), + ] diff --git a/youngjin.han/django/mysite/polls/views.py b/youngjin.han/django/mysite/polls/views.py new file mode 100644 index 0000000..4a60b61 --- /dev/null +++ b/youngjin.han/django/mysite/polls/views.py @@ -0,0 +1,11 @@ +# -*- coding: utf-8 -*- +from __future__ import unicode_literals + +from django.shortcuts import render + +# Create your views here. +from django.http import HttpResponse + + +def index(request): + return HttpResponse("Hello, world. You're at the polls index.") diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index 0f5c6aa..30c2b1d 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -1,3 +1,39 @@ +* 2020-07-04 +*** Django #2: Tutorial 2 +**** DONE Lecture content + CLOSED: [2020-07-04 토 01:03] + - Tutorial 2 of Django + - Environment like in Django 1 + - https://docs.djangoproject.com/en/3.0/intro/tutorial02/ + - If you have IPv6, allow others to acces your Django server + with: + - python manage.py runserver '[::]:8000' +* 2020-06-28 +*** Django #1: Introduction +**** Objective + - We will build a IPv6 ULA registry with Django in the + next lectures +**** DONE Lecture content + CLOSED: [2020-07-04 토 01:03] + - Create a new directory in your learning cirle repository named "django" + - Write down the answers to the following questions in django/django.org + - Research and answer the following questions: (1/2 of the time) + - What is IPv6 ULA? + - Which registries did exist historically? + - How should an IPv6 ULA registry work? + - Get started with Django + - Create a new python virtual env using `python3 -m venv` + - Create the venv in django/venv + - Create a file .gitignore in django/ + - Add 'venv/' (without the quotes to that file + - Use magit to verify that the venv is being ignored + - Add and commit the .gitignore file + - Inside this virtual env, install django using `pip` + - Go to https://www.djangoproject.com/ + - Finish tutorial 1: https://docs.djangoproject.com/en/3.0/intro/tutorial01/ + - Commit the django code to your repository + - Exclude '*.pyc' in the .gitignore + - Also exclude the sqlite database * 2020-06-17 *** Python #11: **** DONE Lecture content From 435eb4f35a76f19b0abd7cb5971f33f35fbc1f31 Mon Sep 17 00:00:00 2001 From: Youngjin Han Date: Tue, 14 Jul 2020 00:28:50 +0900 Subject: [PATCH 2/2] Learning Circle : django #3 - #6 - Tutorial03 - 06 --- youngjin.han/django/django.org | 12 ++ youngjin.han/django/mysite/db.sqlite3 | Bin 143360 -> 143360 bytes youngjin.han/django/mysite/mysite/settings.py | 6 +- youngjin.han/django/mysite/polls/admin.py | 3 + youngjin.han/django/mysite/polls/models.py | 4 +- .../polls/static/polls/images/background.jpg | Bin 0 -> 13672 bytes .../mysite/polls/static/polls/style.css | 7 + .../mysite/polls/templates/polls/detail.html | 12 ++ .../mysite/polls/templates/polls/index.html | 13 ++ .../mysite/polls/templates/polls/results.html | 9 ++ youngjin.han/django/mysite/polls/tests.py | 128 ++++++++++++++++++ youngjin.han/django/mysite/polls/urls.py | 16 ++- youngjin.han/django/mysite/polls/views.py | 106 ++++++++++++++- youngjin.han/learning-node02-2020.org | 85 ++++++++++++ 14 files changed, 394 insertions(+), 7 deletions(-) create mode 100644 youngjin.han/django/mysite/polls/static/polls/images/background.jpg create mode 100644 youngjin.han/django/mysite/polls/static/polls/style.css create mode 100644 youngjin.han/django/mysite/polls/templates/polls/detail.html create mode 100644 youngjin.han/django/mysite/polls/templates/polls/index.html create mode 100644 youngjin.han/django/mysite/polls/templates/polls/results.html diff --git a/youngjin.han/django/django.org b/youngjin.han/django/django.org index 2b11edd..1c79eb5 100644 --- a/youngjin.han/django/django.org +++ b/youngjin.han/django/django.org @@ -1,3 +1,15 @@ +* 2020-07-13 +** note + - none +* 2020-07-10 +** note + - none +* 2020-07-08 +** note + - none +* 2020-07-06 +** note + - none * 2020-07-04 ** note - none diff --git a/youngjin.han/django/mysite/db.sqlite3 b/youngjin.han/django/mysite/db.sqlite3 index 059e514a489eb744fdaa0cf81c053c2021175250..c1315a71c38fa673fd2a88827c8b0a00b5fc5613 100644 GIT binary patch delta 203 zcmZp8z|ru4V}dlJ=|mZ4M$?T6E8>~>4sC4Q#mB^Gx3STRaZ&*X6aSsff(cjo8C51W zDr{0o~enY zv4K(Zh56er%xAO+VB&uSH0m}#qufMCsVz*50=)bm8JPGlG4NmFf5d+ZD7T;ASdsw< u_!wCkWEnaA@=FwQOOrF$c$rukq!~FwGExRlpkSE-lK=qyr8I;9 delta 127 zcmV-_0D%91;0S==2#^~AB#|6L0VJ_ts9&=P;P@Z1fCdl*asUrGiRA^-&b8C4G0R;dZ2nkMabRcbYV`!!z0uZ@RCnf*@ diff --git a/youngjin.han/django/mysite/mysite/settings.py b/youngjin.han/django/mysite/mysite/settings.py index 5661f86..76cb072 100644 --- a/youngjin.han/django/mysite/mysite/settings.py +++ b/youngjin.han/django/mysite/mysite/settings.py @@ -27,6 +27,9 @@ DEBUG = True ALLOWED_HOSTS = [ "[2a0a:e5c1:120::35]", + "192.168.0.20", + "127.0.0.1", + "2a0a-e5c1-0120-0000-0000-0000-0000-0035.has-a.name", ] @@ -108,7 +111,8 @@ AUTH_PASSWORD_VALIDATORS = [ LANGUAGE_CODE = 'en-us' -TIME_ZONE = 'UTC' +#TIME_ZONE = 'UTC' +TIME_ZONE = 'Asia/Seoul' USE_I18N = True diff --git a/youngjin.han/django/mysite/polls/admin.py b/youngjin.han/django/mysite/polls/admin.py index 13be29d..a753d0f 100644 --- a/youngjin.han/django/mysite/polls/admin.py +++ b/youngjin.han/django/mysite/polls/admin.py @@ -4,3 +4,6 @@ from __future__ import unicode_literals from django.contrib import admin # Register your models here. +from .models import Question + +admin.site.register(Question) diff --git a/youngjin.han/django/mysite/polls/models.py b/youngjin.han/django/mysite/polls/models.py index 0383cd4..c6f43bd 100644 --- a/youngjin.han/django/mysite/polls/models.py +++ b/youngjin.han/django/mysite/polls/models.py @@ -16,7 +16,9 @@ class Question(models.Model): def __str__(self): return self.question_text def was_published_recently(self): - return self.pub_date >= timezone.now() - datetime.timedelta(days=1) +# return self.pub_date >= timezone.now() - datetime.timedelta(days=1) + now = timezone.now() + return now - datetime.timedelta(days=1) <= self.pub_date <= now class Choice(models.Model): question = models.ForeignKey(Question, on_delete=models.CASCADE) diff --git a/youngjin.han/django/mysite/polls/static/polls/images/background.jpg b/youngjin.han/django/mysite/polls/static/polls/images/background.jpg new file mode 100644 index 0000000000000000000000000000000000000000..0337b06760b4be988bfa39fd8500e299b4014552 GIT binary patch literal 13672 zcmcI~1yEc|x9%PW_rcvQSa5fTAi;wrxRXGzK!8Bd;1(>nyM_=n_~7pD?vmiV$$9tQ zzh3?4B_%E)4IK>y9T^2B z#cv}Zm?{z?5+*V-CIub@kK%t!kL>^i8B_@dz#tj`4gvy0K#!dO82|!62rzH|MM!X9 zcmzb`-&|4{0}lLua6z!aAi^O%&H?CP7!wa}L8Rzdtmo4t@R@?PZ zHLEgAwWfj(Bi5Z{ujRy+@UjSh(OuB}!5tWa*k{cxEd?Knn!FySch6{#C##zb?FYuu z_W3-I^PDdZYvV1U`+QLzR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lq!cM4VTUsZS~Ynd6Y!LyyQMO;t_yfy*ASfaeVFpN0biewPGSe zr9RofvWbtfKs6xw9=Y_C9FO8?B61^;j10u;V}Fkf7tEKI8fDEP6ANfW5M*L}@@*%d zMJ>f&ghz_Btj7K>~5@HIZSzsy!S{MCt;*&+MzSlhd$6u<-$ z;co&nV}VpiR0WE-_5eFTEs!^WE5!j%n;iVfgRI3`j)R($7<7UH2>>x5U+$&C)g$98 zu!5dWH*6R$phO6jQ&GV)wtwc?eek{PK0kD)lRsm9Cn56YJ~V-Ff`d>1BDbW}Q^*Wh z9-)vnzXd;e*1U&MC;=TAew(crEp#VLwQ32V zU>WA6|3t(e=SKiKoIaY8(BZQuo&;86FxbQ45F?c6CNu7L!21QaKbg(^2$$9AXNuA8 z|G6g!93J!)E&}icVa_TJGf@nTtZ|lq#9a&3+|?yWm&i3G{TRW4yp$b^5(Gk=MHXX< zC?|LZ%rZ+(oXmYisyYtDP=mS&{aTc3nX;!VWBnjalo=P_r-Rv)=;FH$01Wo<$0vj5 zO2mXbDg#|D!9rzi7&BRPD$LnrNLQ5{?odf8-u5tGNL~!lPwO*&V>NZ_LgEdJQEqDh zTQTih__vS1MNwY#r~@;HsQ*Vd?hAxO?N#?9r#SxaD<^N^M;`)jm7IQFl63K=o2adj HKF{{ question.question_text }} + +{% if error_message %}

{{ error_message }}

{% endif %} + +
+{% csrf_token %} +{% for choice in question.choice_set.all %} + +
+{% endfor %} + +
diff --git a/youngjin.han/django/mysite/polls/templates/polls/index.html b/youngjin.han/django/mysite/polls/templates/polls/index.html new file mode 100644 index 0000000..366983e --- /dev/null +++ b/youngjin.han/django/mysite/polls/templates/polls/index.html @@ -0,0 +1,13 @@ +{% load static %} + + + +{% if latest_question_list %} + +{% else %} +

No polls are available.

+{% endif %} diff --git a/youngjin.han/django/mysite/polls/templates/polls/results.html b/youngjin.han/django/mysite/polls/templates/polls/results.html new file mode 100644 index 0000000..3faf8e4 --- /dev/null +++ b/youngjin.han/django/mysite/polls/templates/polls/results.html @@ -0,0 +1,9 @@ +

{{ question.question_text }}

+ +
    + {% for choice in question.choice_set.all %} +
  • {{ choice.choice_text }} -- {{ choice.votes }} vote{{ choice.votes|pluralize }}
  • + {% endfor %} +
+ +Vote again? diff --git a/youngjin.han/django/mysite/polls/tests.py b/youngjin.han/django/mysite/polls/tests.py index 5982e6b..99dd7d0 100644 --- a/youngjin.han/django/mysite/polls/tests.py +++ b/youngjin.han/django/mysite/polls/tests.py @@ -4,3 +4,131 @@ from __future__ import unicode_literals from django.test import TestCase # Create your tests here. +import datetime + +from django.test import TestCase +from django.utils import timezone +from django.urls import reverse + +from .models import Question + + +class QuestionModelTests(TestCase): + + def test_was_published_recently_with_future_question(self): + """ + was_published_recently() returns False for questions whose pub_date + is in the future. + """ + time = timezone.now() + datetime.timedelta(days=30) + future_question = Question(pub_date=time) + self.assertIs(future_question.was_published_recently(), False) + + + def test_was_published_recently_with_old_question(self): + """ + was_published_recently() returns False for questions whose pub_date + is older than 1 day. + """ + time = timezone.now() - datetime.timedelta(days=1, seconds=1) + old_question = Question(pub_date=time) + self.assertIs(old_question.was_published_recently(), False) + + def test_was_published_recently_with_recent_question(self): + """ + was_published_recently() returns True for questions whose pub_date + is within the last day. + """ + time = timezone.now() - datetime.timedelta(hours=23, minutes=59, seconds=59) + recent_question = Question(pub_date=time) + self.assertIs(recent_question.was_published_recently(), True) + + +def create_question(question_text, days): + """ + Create a question with the given `question_text` and published the + given number of `days` offset to now (negative for questions published + in the past, positive for questions that have yet to be published). + """ + time = timezone.now() + datetime.timedelta(days=days) + return Question.objects.create(question_text=question_text, pub_date=time) + + +class QuestionIndexViewTests(TestCase): + def test_no_questions(self): + """ + If no questions exist, an appropriate message is displayed. + """ + response = self.client.get(reverse('polls:index')) + self.assertEqual(response.status_code, 200) + self.assertContains(response, "No polls are available.") + self.assertQuerysetEqual(response.context['latest_question_list'], []) + + def test_past_question(self): + """ + Questions with a pub_date in the past are displayed on the + index page. + """ + create_question(question_text="Past question.", days=-30) + response = self.client.get(reverse('polls:index')) + self.assertQuerysetEqual( + response.context['latest_question_list'], + [''] + ) + + def test_future_question(self): + """ + Questions with a pub_date in the future aren't displayed on + the index page. + """ + create_question(question_text="Future question.", days=30) + response = self.client.get(reverse('polls:index')) + self.assertContains(response, "No polls are available.") + self.assertQuerysetEqual(response.context['latest_question_list'], []) + + def test_future_question_and_past_question(self): + """ + Even if both past and future questions exist, only past questions + are displayed. + """ + create_question(question_text="Past question.", days=-30) + create_question(question_text="Future question.", days=30) + response = self.client.get(reverse('polls:index')) + self.assertQuerysetEqual( + response.context['latest_question_list'], + [''] + ) + + def test_two_past_questions(self): + """ + The questions index page may display multiple questions. + """ + create_question(question_text="Past question 1.", days=-30) + create_question(question_text="Past question 2.", days=-5) + response = self.client.get(reverse('polls:index')) + self.assertQuerysetEqual( + response.context['latest_question_list'], + ['', ''] + ) + + +class QuestionDetailViewTests(TestCase): + def test_future_question(self): + """ + The detail view of a question with a pub_date in the future + returns a 404 not found. + """ + future_question = create_question(question_text='Future question.', days=5) + url = reverse('polls:detail', args=(future_question.id,)) + response = self.client.get(url) + self.assertEqual(response.status_code, 404) + + def test_past_question(self): + """ + The detail view of a question with a pub_date in the past + displays the question's text. + """ + past_question = create_question(question_text='Past Question.', days=-5) + url = reverse('polls:detail', args=(past_question.id,)) + response = self.client.get(url) + self.assertContains(response, past_question.question_text) diff --git a/youngjin.han/django/mysite/polls/urls.py b/youngjin.han/django/mysite/polls/urls.py index ee00c7d..6eebdcb 100644 --- a/youngjin.han/django/mysite/polls/urls.py +++ b/youngjin.han/django/mysite/polls/urls.py @@ -2,6 +2,18 @@ from django.urls import path from . import views +app_name = 'polls' urlpatterns = [ - path('', views.index, name='index'), - ] + # ex: /polls/ + #path('', views.index, name='index'), + path('', views.IndexView.as_view(), name='index'), + # ex: /polls/5/ + #path('/', views.detail, name='detail'), + path('/', views.DetailView.as_view(), name='detail'), + # ex: /polls/5/results/ + #path('/results/', views.results, name='results'), + path('/results/', views.ResultsView.as_view(), name='results'), + # ex: /polls/5/vote/ + #path('/vote/', views.vote, name='vote'), + path('/vote/', views.vote, name='vote'), +] diff --git a/youngjin.han/django/mysite/polls/views.py b/youngjin.han/django/mysite/polls/views.py index 4a60b61..427bf61 100644 --- a/youngjin.han/django/mysite/polls/views.py +++ b/youngjin.han/django/mysite/polls/views.py @@ -4,8 +4,108 @@ from __future__ import unicode_literals from django.shortcuts import render # Create your views here. -from django.http import HttpResponse +from django.http import HttpResponse, HttpResponseRedirect +from django.template import loader +from django.http import Http404 +from django.shortcuts import get_object_or_404, render +from django.urls import reverse +from django.views import generic +from django.utils import timezone + +from .models import Choice, Question -def index(request): - return HttpResponse("Hello, world. You're at the polls index.") +#def index(request): +# return HttpResponse("Hello, world. You're at the polls index.") + +#def index(request): +# latest_question_list = Question.objects.order_by('-pub_date')[:5] +# output = ', '.join([q.question_text for q in latest_question_list]) +# return HttpResponse(output) + +#def index(request): +# latest_question_list = Question.objects.order_by('-pub_date')[:5] +# template = loader.get_template('polls/index.html') +# context = { +# 'latest_question_list': latest_question_list, +# } +# return HttpResponse(template.render(context, request)) + +#def index(request): +# latest_question_list = Question.objects.order_by('-pub_date')[:5] +# context = {'latest_question_list': latest_question_list} +# return render(request, 'polls/index.html', context) + +class IndexView(generic.ListView): + template_name = 'polls/index.html' + context_object_name = 'latest_question_list' + +# def get_queryset(self): +# """Return the last five published questions.""" +# return Question.objects.order_by('-pub_date')[:5] + + def get_queryset(self): + """ + Return the last five published questions (not including those set to be + published in the future). + """ + return Question.objects.filter( + pub_date__lte=timezone.now() + ).order_by('-pub_date')[:5] + +#def detail(request, question_id): +# return HttpResponse("You're looking at question %s." % question_id) + +#def detail(request, question_id): +# try: +# question = Question.objects.get(pk=question_id) +# except Question.DoesNotExist: +# raise Http404("Question does not exist") +# return render(request, 'polls/detail.html', {'question': question}) + +#def detail(request, question_id): +# question = get_object_or_404(Question, pk=question_id) +# return render(request, 'polls/detail.html', {'question': question}) + +class DetailView(generic.DetailView): + model = Question + template_name = 'polls/detail.html' + + def get_queryset(self): + """ + Excludes any questions that aren't published yet. + """ + return Question.objects.filter(pub_date__lte=timezone.now()) + +#def results(request, question_id): +# response = "You're looking at the results of question %s." +# return HttpResponse(response % question_id) + +#def results(request, question_id): +# question = get_object_or_404(Question, pk=question_id) +# return render(request, 'polls/results.html', {'question': question}) + +class ResultsView(generic.DetailView): + model = Question + template_name = 'polls/results.html' + +#def vote(request, question_id): +# return HttpResponse("You're voting on question %s." % question_id) + +def vote(request, question_id): + question = get_object_or_404(Question, pk=question_id) + try: + selected_choice = question.choice_set.get(pk=request.POST['choice']) + except (KeyError, Choice.DoesNotExist): + # Redisplay the question voting form. + return render(request, 'polls/detail.html', { + 'question': question, + 'error_message': "You didn't select a choice.", + }) + else: + selected_choice.votes += 1 + selected_choice.save() + # Always return an HttpResponseRedirect after successfully dealing + # with POST data. This prevents data from being posted twice if a + # user hits the Back button. + return HttpResponseRedirect(reverse('polls:results', args=(question.id,))) diff --git a/youngjin.han/learning-node02-2020.org b/youngjin.han/learning-node02-2020.org index 30c2b1d..4c34b04 100644 --- a/youngjin.han/learning-node02-2020.org +++ b/youngjin.han/learning-node02-2020.org @@ -1,3 +1,88 @@ +* 2020-07-15 +*** Django #7: Tutorial 6 +**** Lecture content + - Environment like in Django 1 and Django 3 + - Ensure your nginx is working + - Paste the URL of your Django server into the chat + - Ensure you can reach the other Django servers + - Follow steps on https://docs.djangoproject.com/en/3.0/intro/tutorial06/ +*** Django #8: Tutorial 7 +**** Lecture content + - Environment like in Django 1 and Django 3 + - Ensure your nginx is working + - Paste the URL of your Django server into the chat + - Ensure you can reach the other Django servers + - Follow steps on https://docs.djangoproject.com/en/3.0/intro/tutorial07/ +* 2020-07-13 +*** Django #6: Tutorial 5 +**** DONE Lecture content + CLOSED: [2020-07-14 화 00:25] + - Environment like in Django 1 and Django 3 + - Ensure your nginx is working + - Follow steps on https://docs.djangoproject.com/en/3.0/intro/tutorial05/ + +* 2020-07-10 +*** Django #5: Tutorial 4 +**** DONE Lecture content + CLOSED: [2020-07-14 화 00:19] + - Environment like in Django 1 and Django 3 + - Ensure your nginx is working + - Follow steps on https://docs.djangoproject.com/en/3.0/intro/tutorial04/ + +* 2020-07-08 +*** Django #4: Tutorial 3 +**** DONE Lecture content + CLOSED: [2020-07-14 화 00:18] + - Environment like in Django 1 and Django 3 + - Ensure your nginx is working + - Follow steps on https://docs.djangoproject.com/en/3.0/intro/tutorial03/ +* 2020-07-06 +*** Django #3: using http and https +**** DONE Lecture content + CLOSED: [2020-07-14 화 00:17] + - We want expose our Django app via https to the world + - We want to allow IPv6 world wide access + - Steps IPv6 + - Ensure you have IPv6 connectivity + - Get a VPN from IPv6VPN.ch if you don't have IPv6 + - Ensure that your firewall allows access to ports 80 and 443 + to your machine + - Coordinate with another participant to test your connection + - The square brackets are needed in the following examples + - curl -vv http://[your ipv6 address] + - curl -vv https://[your ipv6 address] + - Both examples should return "connection refused" + - Find out your Domain name + - We will install an letsencrypt certificate + - Certificates need a name + - The website https://has-a.name provides you with a name + - Find out your name + - Have somebody else ping your name + - Steps webserver + - Install nginx + - Have somebody else run curl -v http://.has-a.name + - Install certbot + - Use certbot to request a certificate for your name + - Use the nginx plugin of certbot + - Have somebody else run curl -v https://.has-a.name + (with httpS!) + - Proxy configuration + - We want nginx to forward the HTTPS requests to django + - We run django on the IPv6 localhost + - python manage.py runserver '[::1]:8000' + - Note: this is different from last session! + - We configure nginx to proxy to django + - Locate the configuration file for the https server (usually + somewhere below /etc/nginx) + - Add a proxy configuration to it + - The proxy block looks similar to this: + location / { + proxy_pass http://localhost:8000; + proxy_set_header Host $host; + proxy_set_header X-Real-IP $remote_addr; + } + - Test with the other participants to reach you! + - Add your nginx configuration * 2020-07-04 *** Django #2: Tutorial 2 **** DONE Lecture content