Error when using filter to query Decimalfield type variable
ddx64 opened this issue · 0 comments
ddx64 commented
One line description of the issue
Environment: djongo 1.3.6, Django 3.1.12
Python script
from djongo import models
class xxx(models.Model):
price = models.DecimalField(max_digits=10, decimal_places=2)
# commands under Django shell
from aaa.models import xxx
from bson.decimal128 import Decimal128
xxx.objects.filter(price=Decimal128('20.55'))
# I tried using deicmal.Decimal, but that would raise another probelm:
# bson.errors.InvalidDocument: cannot encode object: Decimal('20.55'), of type: <class 'decimal.Decimal'>
Traceback
Traceback (most recent call last):
TypeError: conversion from Decimal128 to Decimal is not supported
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
django.core.exceptions.ValidationError: ['“20.55”should be a decimal numeral。']