'output_field argument of expressionwrapper not identifying any field
while using ExpressionWrapper i am not able set output_field=DecimalField() i am getting error like
- Exception Type: NameError
- Exception Value: name 'DecimalField' is not defined
help me out with this
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)})
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
