I’m new to django and coding a blog app.I have an issue about urls. When I click a page,ex:about,url is http://localhost/about But in this page,when clicking an object on main contents,ex:in categories linux, the given url’s turning like this: http://localhost/about/tags/linux
and as guessed, isn’t showed anything.
The url must be shown like http://localhost/tags/.. How can I get over this?
I’m new to django and coding a blog app.I have an issue about urls.
Share
How are you creating urls in your template?
You should have defined names for your urls in urls.py.
If you define a url with the name ‘about’ your can use {% url about %} to get the full correct path.
For something more dynamic like your tags/linux you might define a url ‘tags’ which takes the tag name as argument and you’d generate the url in the template with {% url tags ‘linux’ %}.
The important parts of this is introduced in the canonical introduction to Django: https://docs.djangoproject.com/en/dev/intro/tutorial01/