From b124d1bef876b3cc08fe7a53999d7cb8bb896e62 Mon Sep 17 00:00:00 2001 From: Neil Smith Date: Wed, 5 Oct 2016 10:25:07 +0100 Subject: [PATCH] Done first view --- .gitignore | 4 ++++ blog/templates/blog/post_list.html | 23 +++++++++++++++++++++++ blog/urls.py | 6 ++++++ blog/views.py | 3 ++- mysite/urls.py | 3 ++- 5 files changed, 37 insertions(+), 2 deletions(-) create mode 100644 blog/templates/blog/post_list.html create mode 100644 blog/urls.py diff --git a/.gitignore b/.gitignore index 42365e0..f6cc5da 100644 --- a/.gitignore +++ b/.gitignore @@ -49,3 +49,7 @@ nosetests.xml # Virtual environment djangogirls + +# Django static files +/static +.DS_Store diff --git a/blog/templates/blog/post_list.html b/blog/templates/blog/post_list.html new file mode 100644 index 0000000..aa9d1d5 --- /dev/null +++ b/blog/templates/blog/post_list.html @@ -0,0 +1,23 @@ + + + + Neil's blog + + + +
+

Django Girls Blog

+
+
+

published: 14.06.2014, 12:14

+

My first post

+

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 rmentum mass a justo sit amet risus.

+
+
+

published: 14.06.2014, 12:14

+

My second post

+

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.

+
+ + + \ No newline at end of file diff --git a/blog/urls.py b/blog/urls.py new file mode 100644 index 0000000..eecfb5f --- /dev/null +++ b/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'), +] \ No newline at end of file diff --git a/blog/views.py b/blog/views.py index 91ea44a..299ca35 100644 --- a/blog/views.py +++ b/blog/views.py @@ -1,3 +1,4 @@ from django.shortcuts import render -# Create your views here. +def post_list(request): + return render(request, 'blog/post_list.html', {}) diff --git a/mysite/urls.py b/mysite/urls.py index bc15726..df6b88d 100644 --- a/mysite/urls.py +++ b/mysite/urls.py @@ -13,9 +13,10 @@ 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.conf.urls import include, url from django.contrib import admin urlpatterns = [ url(r'^admin/', admin.site.urls), + url('', include('blog.urls')), ] -- 2.34.1