Аргумент output_field в expressionwrapper не идентифицирует ни одно поле

при использовании ExpressionWrapper я не могу установить output_field=DecimalField() я получаю ошибку типа

  1. Exception Type: NameError
  2. Exception Value: name 'DecimalField' is not defined

помогите мне с этим

from django.shortcuts import render
from django.db.models import Value, F, ExpressionWrapper
from store.models import Customer, Product

def say_hello(request):
    discounted_price = ExpressionWrapper(
        F('unit_price') * 0.8, output_field=DecimalField())
    queryset = Product.objects.annotate(discounted_price=discounted_price)

    return render(request, 'hello.html', {'name': 'Ashish', 'result': list(queryset)})
Вернуться на верх