Join Caleb Smith for an in-depth discussion in this video Using URLs, views, and templates, part of Learning Python and Django (2015).
- Broadly, Django uses an MVC, or…Model View Controller, architecture.…However, Django calls these pieces by different names.…The four pieces to understand for Django are:…URL patterns, views, models, and templates.…Each of these pieces has a separate role.…The URL patterns take the path of a request and decide…which views should handle the request.…The patters for our project are…defined in firstdjango/urls.py…Given a request, the URL patters pass control to the views.…
Views are the logic layer of the program, which…are pythons functions that take a…request and return an HTTP response.…Our views are defined in inventory/views.py…Each view can use the models we have defined in…inventory/models.py to query the database as needed.…Each view relies on a corresponding template to…help with the presentation layer of what the HTML will look…like. Each template is a separate file that consists of…HTML with some extra template syntax.…
We haven't created any templates yet, but they…will live in the firstdjango/templates folder.…
- Creating a new Django project
- Defining Django models and fields
- Querying data with the Django ORM
- Building views and templates
Skill Level Intermediate
Q: pip says it was installed correctly, and I've updated the PATH variable as shown, but the pip --version command isn't working. Why?
A: Depending on your computer's setup, you'll need to restart your terminal/command prompt before the additions you've made to the PATH variable are respected. With some setups, even that won't be enough, and you may need to restart the entire machine before you are able to use the pip command directly.