# Remove decimal prefix from queryset django

**URL:** <https://forum.djangoproject.com/t/remove-decimal-prefix-from-queryset-django/5160>\
**Category:** Using Django\
**Created:** [November 10, 2020, 9:33am UTC](https://forum.djangoproject.com/t/remove-decimal-prefix-from-queryset-django/5160 "2020-11-10T09:33:56Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![IFarhat](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/ifarhat/32/2283_2.png) [@IFarhat](https://forum.djangoproject.com/u/IFarhat)\
**Post date:** [November 10, 2020, 9:33am UTC](https://forum.djangoproject.com/t/remove-decimal-prefix-from-queryset-django/5160/1 "2020-11-10T09:33:56Z")

</div>

Hello,

If I run the following query `list(Macro.objects.values_list('value', flat=True))`, I get the following output

```auto
[Decimal('11.16'), Decimal('7.63'), Decimal('8.53'), Decimal('12.99'), Decimal('15.09'), Decimal('13.03'), Decimal('11.35'), Decimal('9.58'), Decimal('9.29'), Decimal('11.56'), Decimal('10.35'), Decimal('9.23'), Decimal('9.84'), Decimal('13.29'), Decimal('14.09'), Decimal('10.82'), Decimal('8.91'), Decimal('5.21'), Decimal('5.16'), Decimal('6.33'), Decimal('5.78'), Decimal('6.50'), Decimal('6.81'), Decimal('5.04'), Decimal('5.80'), Decimal('4.76'), Decimal('3.86'), Decimal('3.56'), Decimal('4.44'), Decimal('4.55'), Decimal('4.65'), Decimal('5.53'), Decimal('4.28'), Decimal('0.49'), Decimal('0.50'), Decimal('0.48'), Decimal('0.31'), Decimal('0.30'), Decimal('0.38'), Decimal('0.44'), Decimal('0.32')]

```

How do I remove the decimal prefix from a queryset Django?

---

<div class="post-metadata">

**Author:** ![mleasi](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/mleasi/32/2179_2.png) [@mleasi](https://forum.djangoproject.com/u/mleasi)\
**Post date:** [November 10, 2020, 2:42pm UTC](https://forum.djangoproject.com/t/remove-decimal-prefix-from-queryset-django/5160/2 "2020-11-10T14:42:47Z")

</div>

I don’t know if it’s important to you:

your queryset:  
` qset = Macro.objects.values_list('value', flat=True)`

If you print single item

`qset[x]`

or all items

```
for item in qset:
    print(item)

```

you don’t see Decimal prefix

But in the extreme you can create a new float list

`newlist = [float(i) for i in qset]`

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [November 10, 2020, 3:25pm UTC](https://forum.djangoproject.com/t/remove-decimal-prefix-from-queryset-django/5160/3 "2020-11-10T15:25:28Z")

</div>

The Decimal datatype in Python is the appropriate representation of a database decimal field. If you want to convert it away from type Decimal, you need to decide whether to want to convert it to a string or a float. (Strings can then be accurately re-encoded as Decimal if you need to do math on them, floats aren’t an exact representation, but math operations can be performed on them directly.)  
Either way, you would most likely be able to use the [Cast](https://docs.djangoproject.com/en/3.1/ref/models/database-functions/#cast) function to convert the data to a different type within the query.

In the end, it comes down to what you’re going to be doing with the result set from your query.
