I am trying to pass values from the views.py to the HTML to be displayed but a list is being passed instead of a single value.
I have a random link that should randomly pick an item from the list,
this is the HTML where the item should link to
<a href="{{entries}}">Random{{entries}}</a>
this is the views.py
def rando(request, title):
items = util.list_entries()
randomitem = Random.choice(items)
return render(request, "encyclopedia/view.html", {
"entries": md.convert(util.get_entry(randomitem))
})
this is the error I receive
TypeError at /wiki/['CSS', 'Django', 'Git', 'HTML', 'Python']
the random link in the HTML should pass only one of the items on the list.
can anyone help me with a solution
items = choice(util.list_entries())
randomitem = util.get_entry(items)
return render(request, "encyclopedia/view.html", {
"title": items,
"entries": md.convert(randomitem)
})
updated the code. works fine now