Django: how to use float precision instead of double precision in MySQL

models.FloatFieldcreates a double in MySQL.
Is it possible, and how to create a precision field float instead of double precision?

The rationale is similar to what SmallIntegerField has.

+3
source share
2 answers

There are several options for this, but I don’t understand why you want to.

+2

, , . , db, db_type() django.

django, Field

class customFloatField(models.Field): 
    def db_type(self,connection):
        return 'float'

number = customFloatField(null=True,blank=True)

, MySQL. , if .

https://docs.djangoproject.com/en/dev/howto/custom-model-fields/

+3

Source: https://habr.com/ru/post/1777916/


All Articles