From 233ff7bb5add76328581e6b95457f9e6751d9ad1 Mon Sep 17 00:00:00 2001 From: prathamesh Date: Thu, 26 Apr 2018 17:47:27 +0530 Subject: Change completely script 8 Instead of improving html templates, showed how to use static files like css and js in django. --- tutorial_5_django_templates/slides.md | 23 +++- tutorial_8_better_UI/slides.md | 195 +++++++++------------------------- 2 files changed, 71 insertions(+), 147 deletions(-) diff --git a/tutorial_5_django_templates/slides.md b/tutorial_5_django_templates/slides.md index 4a149f6..76c4978 100644 --- a/tutorial_5_django_templates/slides.md +++ b/tutorial_5_django_templates/slides.md @@ -55,6 +55,21 @@ Slide 5 [00:18 | 01:00] In this directory create an *blogs.html* file and add the below code # /blog/templates/blog/blogs.html + + +
+ {% if blogs %} +No Blogs are available.
+ {% endif %} + + + {% if articles %}No Blogs are available.
- {% endif %} - -Slide 7: ---------------------- +**Create a folder static in blogs directory** -**Modify the URLs** + mkdir static -- Modify the urls located in the ```myproject``` folder +- Create blog folder inside static - # /myproject/urls.py - from django.conf.urls import include, url - from django.contrib import admin - from blog import urls + cd static + mkdir blog - urlpatterns = [ - url(r'^admin/', admin.site.urls), - url(r'^blog/$', blog.urls) # Change this line - ] +- Create a base CSS file inside blog -- Modify the urls located in the ```blogs``` folder + cd blog + gedit blogs.css & - # /blogs/urls.py - from django.conf.urls import patterns, url - from blog import urls - urlpatterns = [ - url(r'^(?PCreated: {{ article.created_on }}
-
- {{ article.body}} -
- {% else %} -No Articles are available for this blog.
- {% endif %} - -Slide 10b: -------------------- - -**Modify the blog template** - -- We need to add a link to each article in the blog list page ```/blog/templates/blog/blogs.html``` so that a user can view an articles - - {% if blogs %} -No Blogs are available.
- {% endif %} - -Slide 11 -------------------------- - -**Add URLs for articles_list** - -- We need to add a new URL in ```/blogs/urls.py``` which will point to the articles_list view. -- When selecting a particular blog the URL should look like ```localhost:8000/blog/