doableware / djongo

Django and MongoDB database connector
https://www.djongomapper.com
GNU Affero General Public License v3.0
1.86k stars 352 forks source link

Error when using filter to query Decimalfield type variable #609

Open ddx64 opened 2 years ago

ddx64 commented 2 years ago

One line description of the issue

Environment: djongo 1.3.6, Django 3.1.12

Python script

```python 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: ``` #### 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。']