Blog View and Template – Django Web Development with Python 7

Video is ready, Click Here to View ×

Welcome to Part 7 of our Django web development with Python tutorial.

After we define our model, we’re ready to define our blog/ file, create any template we need and then we’ll be done, right?! Well, traditionally, we’d also need to modify the blog/ before being done, but nope, we’re going to employ some further Django magic and skip that part entirely with some generic views.

Sample code and text-based tutorial:…


  1. Bro ! Ever since the : urlpatterns = [ url (r'^$',ListView.as_view (queryset=Post.objects.all().order_by("-date")[:25],template_name="blog/blog.html"))]…the entire part of ',ListView.as_view (queryset=Post.objects.all().order_by("-date")[:25]',just went totally above my head.Please explain properly how am I supposed to remember the sequence of arguments,and functions used,and where from am i supposed to reference,when I forget??

  2. Hi Sentdex,

    thank you very much for your content it's very helpful.

    I was wondering if you could also show:
    How the admin can add images to each blog post
    How to add a comment section to each blog post for users.

    If anyone else knows the answer to this i would be very grateful.


  3. Harrison,

    Your tutorials are awesome. I can actually understand the materiel without to many errors and can follow along. This is very helpful and I hope I can use this as a model to build real websites. Thanks.

  4. hello sentdex, I'm really stuck. I have an error here:
    File "", line 3, in <module>
    from blog.model import Post
    ModuleNotFoundError: No module name 'blog.model'.
    I tried the fix mentioned by +Mitch below, didn't work. Please do reply. I really can't go further here. Waiting on your reply

  5. Hello! I'm a first time web-developer biting off a lot, feels like more than I can chew. I've watched your tutorials 3 times now and I'm finally getting rolling on my website. I'm having a problem I don't know how to solve though… My index opens my home.html page which is perfect, but now that I've added my watch.html page like so:
    "from django.conf.urls import url
    from . import views

    urlpatterns = [
    url(r'^$', views.index, name='index'),
    url(r'^watch',, name='watch'),
    Which opens up like it should when I got to The problem I'm having is that even though my watch.html is in the same template folder as my home.html, watch.html tries to access my static folder through a weird extended path that looks like this: /watch/static/myapp/img/etc.png which doesn't exist. My header loads all images perfectly on the home page which extends header.html but won't load any images when visiting watch.html which also extends the same header.html. I'm so lost. Thank you so much for these videos! P.S. I don't want to make a new app for the watch page since it shares the same static files.

  6. I am building a stock page instead of a blog by following your steps. Do i have the following html correct to display my stock data as a table?

    {% extends "home/header.html" %}

    {% block content%}
    <p>Enter some text here</p>
    {% include "home/includes/htmlsnippet.html" %}

    {% for Stocks in object_list %}
    {% endfor %}
    {% endblock%}

Leave a Reply

Your email address will not be published.