53👍
Add /
at start in href
:
<a href="/appname/detail/{{ job.id }}/">{{ job.name }}</a>
And for the url
tag to work you need to do it like this:
<a href="{% url 'appname.views.detail' jobID=job.id %}">{{ job.name }}</a>
2👍
From my experience, as long as you have defined the url of the page the href
tag should lead to in urls.py
, include the absolute path in the format below.
Site name: yyyy.com
Url of page to redirect to in urls.py: yyyy.com/signup/
Sample link: <a href="/signup/">Signup</a>
You will notice that what goes inside the href tag is sort of appended to the current url. For more dynamic links, you can use some python as of DTL guidelines.
- [Django]-Django 1.9 deprecation warnings app_label
- [Django]-Django: how does manytomanyfield with through appear in admin?
- [Django]-What is the path that Django uses for locating and loading templates?
1👍
Suppose u are at
myapp/detail
and u want to go at page
myapp/anything
U shoud do this
<a href="../anything">Page</a>
- [Django]-Django Passing Custom Form Parameters to Formset
- [Django]-Is not JSON serializable
- [Django]-Django REST Framework upload image: "The submitted data was not a file"
1👍
For django templates
Url.py File
app_name = 'app_name'
path('url/', TestView.as_view(), name='the_url'),
path('url//<int:id>', TestView.as_view(), name='the_url'),
templates(html.py)
<a href="{% url 'app_name:the_url' %}">Test</a>
<a href="{% url 'app_name:the_url' id %}">Test</a>
- [Django]-Location of Django logs and errors
- [Django]-Make boolean values editable in list_display?
- [Django]-Django Sitemaps and "normal" views
0👍
I got the same problem, new address is being added after the "/" URL which is not recognised.
Can be solved by adding "/" at the address you are giving at the href attribute.
ex: href:services is wrong
href:/services is to be used to go to services page.
- [Django]-Python- How to flush the log? (django)
- [Django]-ModuleNotFoundError: No module named 'grp' on windows
- [Django]-Which Stack-Overflow style Markdown (WMD) JavaScript editor should we use?