Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

DecimalField getting saved as string #191

Open
Alir3z4 opened this issue Jun 28, 2014 · 0 comments
Open

DecimalField getting saved as string #191

Alir3z4 opened this issue Jun 28, 2014 · 0 comments

Comments

@Alir3z4
Copy link

Alir3z4 commented Jun 28, 2014

MongoDB doesn't support float or decimal field.

If we use a decimal field data will be saved as strings and of course there will be no way to run $gt or $lt operation on them, and this is so misleading.

A solution for this would be to save the rounded number in integer on the model and keep the decimal value in string just for the displaying, but this should be handled by DecimalField itself.

like:

score  = DecimalField()

and should get saved on the database with a extra field to keep the data in rounded integer.

score = "23.548515515"
score_int = 24

and of course that behavior of the the field should be handled by filter too, like running filter(score__gte=13) should be translated to filter(score_int__gte=13), well that might require a lot of work to do.

But after all I guess it would be better to mention DecimalField behavior somewhere on the doc or just mock the DecimalField with IntegerField or something.

I think this kind of issue #112 is related to this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant