Join Caleb Smith for an in-depth discussion in this video Configuring URL patterns, part of Learning Python and Django (2015).
- Let's look at a complete example…and integrate some URL patterns into our project.…In the text editor, navigate to the first django folder…and open the urls.py file.…At the top of the file are some imports that we need to keep…for the include and URL functions on line 1,…and the admin module on line 2.…Next we'll add an import of our own.…From inventory we'll import the views module we've defined.…Next, I'll remove the comments here for the example…since I'm adding my urls now.…For the first pattern, I'll use a pattern…that I introduced earlier in an example.…
This regular expression will match a top level route url…which is just a slash.…For this I'll dispatch to the index view…and I'll name this pattern index.…For the next pattern, I'll introduce a regular expression…we haven't seen yet.…This one begins with item,…and then matches one or more digit characters…with the \d+…This new syntax we haven't seen yet…with the (?P and so on is called a named group.…This named group uses id in angle brackets…to mean that the digit characters will be called id.…
- 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.