So im basically trying to render a random template, but it says that "local variable 'random' referenced before assignment", even though I imported random. this is my code at the top
from django.shortcuts import render
from . import util
import markdown2
import randomthis is my logic
def random(request):
entries = [entry for entry in util.list_entries()]
random = random.choice(entries)
getentry = util.get_entry(random)
return render(request, "encyclopedia/title.html", {
"entryname": markdown2.markdown(getentry)
})
Aucun commentaire:
Enregistrer un commentaire