Templates and Setup
Notice how it uses the
blogs query set sent in by the view. The query set is looped through, printing out the
title attribute of each of the
Blog objects found. Finally, to view an actual blog, create
urls.py file doesn’t import
include(), so note that change to the second line. The rest of the lines import
core/views.py and create the URL patterns for the
view_blog() view functions.
Everything is now in place. Use the following Django management commands to make and migrate the database models and run the server. The last command runs the Django development server. While it’s running, you can use a browser to visit the address shown onscreen to see the
listing page, but without any data.
04:34 Adding Some Data. Since you haven’t created anything yet, the page will only show the title. Visit the Django admin at the address shown onscreen and log in using the superuser credentials you created earlier on.
05:29 The fixture file contains two example blog entries. If you visit the site’s home page, then it should now show some content, as you see onscreen. Now that you have a working blog site with some data in it, next you’ll see how to detect whether users are logged in or not.
Become a Member to join the conversation.