Getting the Project Started
00:00 Getting Started. To better understand authorization, you’ll need a project to experiment with. You’ll run through the creation of a simple blog app to demonstrate the techniques needed. Alternatively, you can follow along by downloading the sample code from this link.
You now have a
Blog project, but you still need to tell Django about the app you created and the new directory you added for templates. You can do this by modifying the
Blog/settings.py file, first by changing the
INSTALLED_APPS list to include the
core app you created earlier on.
The sample site you’ll be working with is a basic blogging application. The
core app needs a
models.py file to contain the models that store the blog content in the database. Edit
core/models.py and add the following.
listing() view does a query looking for all the
Blog objects and passes that to the
render() shortcut function.
render() takes the
request object that provides context to the view, the name of a template to render, and the
data object containing the query set of
view_blog() view takes a
blog_id as a parameter and uses it to look up the corresponding
Blog object. This object is passed as context to the
view_blog.html template through the
render() shortcut. In the next section, you’ll see how templates are constructed in Django and complete the setup of the blog site.
Become a Member to join the conversation.