0

I am a beginner with DJANGO, I am working on a project where one of the models contains a JSONField. In the code at some point i need to detect and process the JSONField only and so I get the internaltype of the fields and if it turns out to be JSON field then I process it.

for field in obj._meta.fields:
            #find the fields with JSONField type
            if obj._meta.get_field(field.name).get_internal_type() == 'JSONField':

It works well on my machine, however when I upload the same code on the server, it does not execute, as, the internaltype of the JSONField is returned as a TextField and the logic fails there. What could be wrong and why is the JSONField being detected as a TextField?

The postgres version being used on the server is 9.6.1

Subbu
  • 588
  • 1
  • 7
  • 18
  • Do you have the same version on your development machine as on production? I'm using 9.6.11 on production and couldn't reproduce your issue. I get JSONField as expected. – dirkgroten Feb 15 '19 at 14:38
  • @dirkgroten Thanks for your efforts! On my development machine I am using postgres version 11.1. Also I am using it from within a docker container. – Subbu Feb 16 '19 at 04:41

0 Answers0