Django Tutorial
About Lesson

In this Django Tutorial we are going to learn about Django Url Tag,  django url tag returns an absolute path reference (a URL without the domain name) matching a given view and optional parameters. This is a way to output links without violating the DRY principle by having to hard-code URLs in your templates.



So first we need to create a new view function for our polls and after that we are going to link the urls in our navbar.html using django url tag. so this is our file.






Now create a new html file at name of polls_list.html for our newly created view.






And now this is our, you need map your newly view function. you can see in this code we have name parameter in our paths, we can use this name with url tag to create absolute path reference.




Now open your navbar.html file and in the href section you need to add this code, you can see that we have used django url template tag for adding a path reference for our urls.



Now this is our complete navbar.html.




This is our rest of files for our django project.























Run your project and click on the Polls from navbar and this will be the result.

Django Tutorial - Django Url Tag
Django Tutorial – Django Url Tag