Thursday, July 20, 2017

Re: How to discover which postgres vesion is in use (on 1.11)?

You can use:

>>> from django.db import connection
>>> connection.pg_version
90507

On Wednesday, July 19, 2017 at 6:15:29 AM UTC-4, HM wrote:
When https://code.djangoproject.com/ticket/18332 lands (No generic way
to get database backend version) this will be trivial but I need a
solution for this now: How can I find out which version of postgres is
in use?

I need it thanks to JSONField. 9.6 has support for it but older
postgresqls don't, and I'd like to then use a third-party
json-in-TextField solution instead.

A model with a django.contrib.postgres.fields.JSONField cannot be
migrated on posgresqls older than 9.4. (We run 9.3 and I need this
project to run on >=9.3) You get 'django.db.utils.ProgrammingError:
type "jsonb" does not exist'. At that point it's a little late
swapping out the import.

--
HM

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/0b735664-8a28-4f1e-be39-224b478924eb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment