Pārlūkot izejas kodu

DjangoGirls Static html view

scadl 6 gadi atpakaļ
vecāks
revīzija
b4551823f7
4 mainītis faili ar 32 papildinājumiem un 0 dzēšanām
  1. 22 0
      blog/templates/blog/post_list.html
  2. 6 0
      blog/urls.py
  3. 2 0
      blog/views.py
  4. 2 0
      mysite/urls.py

+ 22 - 0
blog/templates/blog/post_list.html

@@ -0,0 +1,22 @@
+<html>
+    <head>
+        <title>Django Girls blog</title>
+    </head>
+    <body>
+        <div>
+            <h1><a href="/">Django Girls Blog</a></h1>
+        </div>
+
+        <div>
+            <p>published: 14.06.2014, 12:14</p>
+            <h2><a href="">My first post</a></h2>
+            <p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut fermentum massa justo sit amet risus.</p>
+        </div>
+
+        <div>
+            <p>published: 14.06.2014, 12:14</p>
+            <h2><a href="">My second post</a></h2>
+            <p>Aenean eu leo quam. Pellentesque ornare sem lacinia quam venenatis vestibulum. Donec id elit non mi porta gravida at eget metus. Fusce dapibus, tellus ac cursus commodo, tortor mauris condimentum nibh, ut f.</p>
+        </div>
+    </body>
+</html>

+ 6 - 0
blog/urls.py

@@ -0,0 +1,6 @@
+from django.conf.urls import url
+from . import views
+
+urlpatterns = [
+    url(r'^$', views.post_list, name='post_list'),
+]

+ 2 - 0
blog/views.py

@@ -1,3 +1,5 @@
 from django.shortcuts import render
 
 # Create your views here.
+def post_list(request):
+    return render(request, 'blog/post_list.html', {})

+ 2 - 0
mysite/urls.py

@@ -13,9 +13,11 @@ Including another URLconf
     1. Import the include() function: from django.urls import include, path
     2. Add a URL to urlpatterns:  path('blog/', include('blog.urls'))
 """
+from django.conf.urls import include, url
 from django.contrib import admin
 from django.urls import path
 
 urlpatterns = [
     path('admin/', admin.site.urls),
+    url(r'', include('blog.urls')),
 ]