Answer the question
In order to leave comments, you need to log in
How is a catalog made with the output of categories / subcategories from the database as links?
I can't figure out how to call the list of objects from the secondary table of the database,
so that by clicking on a category, all records of this category will open
on a new page as links.
views.py:
def crafts(request):
craft = MasterCategory.objects.all()
return render(request, 'users/crafts.html', {'crafts': craft})
def master_list(request, ml_id):
masterlist = User.objects.get(ml_id=ml_id)
return render(request, 'users/master_list.html', {'masterlist': masterlist})
url(r'^crafts/$', views.crafts, name='crafts'),
url(r'^crafts/master_list_(?P<ml_id>[0-9]+)/$', views.master_list, name='master_list'),
{%for craft in crafts%}
<a href='master_list/'>{{craft}}</a>
<br>
<br>
{%endfor%}
Answer the question
In order to leave comments, you need to log in
Something like this, just change the data to yours.
<a href="/category/{{category.id}}">{{category.title]}</a>
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question