Closed asing177 closed 8 years ago
Move your cursor over the link and press left mouse button
these are static...cant they be made dynamic...like url 'categories'
@adityasingh177 I absolutely totally don't understand what you're saying. If you want to get dynamic urls for any category instance, use instance.get_absolute_url()
it doesnt work when i am calling the instance.get_absolute_url() from another page that is outside the mptt tree...
You should provide code example.
Categories :- weddings > Dexter and Rita My Pets > Dogs > Husky
'''
'''
i am a beginner. How can i give Links in "a hrefs " here....thanks in advance...
From your views.py pass desired instances to your template, like this:
def another_page(request):
return render(
request,
'another.html',
{'categories': Category.objects.all()}
)
Then in another.html:
{% for category in categories %}
{{ category.get_absolute_url }}
{% endfor %}
Note that in your models.py
file you need to set up def get_absolute_url()
for your Category
model, as described here https://github.com/c0ntribut0r/django-mptt-urls in section get_absolute_url().
how can i access the urls as links?
http://best-photographer.com/gallery/weddings/Dexter-and-Rita/ http://best-photographer.com/gallery/my-pets/dogs/husky/