How postgres data type "real" is represented in Django?

720 views
Skip to first unread message

IgorS

unread,
Jun 12, 2012, 11:50:49 AM6/12/12
to django...@googlegroups.com
Hi ALL!

It seems that there is no class in Django models that represents 4-byte data type "real" in postgres. I looked into django\db\backends\postgresql_psycopg2\creation.py but could not find it there. The only choice seems to be FloatField, which represents "double precision" in postgres. But i would like to use "real" to minimize the index size? How can i do it?


Thank you,
-igor

akaariai

unread,
Jun 14, 2012, 5:18:40 AM6/14/12
to Django users
It might be you will need to do a FloatField subclass - RealField,
which will return "REAL" as its database type from field.db_type(). It
has been a while since last dealing with custom fields so there might
be something more needed. Django's documentation should contain more
information.

- Anssi

IgorS

unread,
Jun 15, 2012, 9:51:16 AM6/15/12
to django...@googlegroups.com
Thanks a lot, Anssi! 
This is very helpful.
Just in case someone else is interested in "Writing custom model fields", here is a link to Django's docs: https://docs.djangoproject.com/en/dev/howto/custom-model-fields/

Thank you once again,
-igor
Reply all
Reply to author
Forward
0 new messages