lundi 13 juillet 2020

random function on working in Django even though I imported it. local variable 'random' referenced before assignment

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 random

this 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