[Python] UnboundLocalError at / local variable 'context' referenced before assignment

Discussão em 'Python' iniciado por Stack, Janeiro 1, 2025.

  1. Stack

    Stack Membro Participativo

    Getting this error with views.py in my Django app - UnboundLocalError at / local variable 'context' referenced before assignment.

    Here is a snippet of the code in my views.py that is not working:

    from django.shortcuts import render
    from .models import *

    def store(request):
    products = Product.objects.all()
    context: {'products':products}
    return render(request, 'store/store.html', context)

    Continue reading...

Compartilhe esta Página