0

Installing project from GitHub repo and receive following error after all

 File "/Users/TheKotik/closer/blog/models.py", line 5, in <module>
    from rest_framework import serializers
  File "/Users/TheKotik/closer/denv/lib/python3.5/site-packages/rest_framework/serializers.py", line 1534, in <module>
    ModelSerializer.serializer_field_mapping[postgres_fields.JSONField] = JSONField
AttributeError: module 'django.contrib.postgres.fields' has no attribute 'JSONField'

Have no idea, what it's related to. Please help..

The whole traceback:

    File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/TheKotik/closer/denv/lib/python3.5/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/Users/TheKotik/closer/denv/lib/python3.5/site-packages/django/core/management/__init__.py", line 312, in execute
    django.setup()
  File "/Users/TheKotik/closer/denv/lib/python3.5/site-packages/django/__init__.py", line 18, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/Users/TheKotik/closer/denv/lib/python3.5/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/Users/TheKotik/closer/denv/lib/python3.5/site-packages/django/apps/config.py", line 198, in import_models
    self.models_module = import_module(models_module_name)
  File "/Library/Frameworks/Python.framework/Versions/3.5/lib/python3.5/importlib/__init__.py", line 126, in import_module
    return _bootstrap._gcd_import(name[level:], package, level)
  File "<frozen importlib._bootstrap>", line 986, in _gcd_import
  File "<frozen importlib._bootstrap>", line 969, in _find_and_load
  File "<frozen importlib._bootstrap>", line 958, in _find_and_load_unlocked
  File "<frozen importlib._bootstrap>", line 673, in _load_unlocked
  File "<frozen importlib._bootstrap_external>", line 665, in exec_module
  File "<frozen importlib._bootstrap>", line 222, in _call_with_frames_removed
  File "/Users/TheKotik/closer/blog/models.py", line 5, in <module>
    from rest_framework import serializers
  File "/Users/TheKotik/closer/denv/lib/python3.5/site-packages/rest_framework/serializers.py", line 1534, in <module>
    ModelSerializer.serializer_field_mapping[postgres_fields.JSONField] = JSONField
AttributeError: module 'django.contrib.postgres.fields' has no attribute 'JSONField'
3
  • compare the version you are using to the github one and tell me Commented Oct 24, 2017 at 16:30
  • ^^ JSONField was introduced in Django 1.9, if you're on something less than that, you won't have it. Commented Oct 24, 2017 at 16:32
  • @wpercy django version is 1.8 Commented Oct 24, 2017 at 16:34

1 Answer 1

2

Your Django version is too low. JSONField was added in Django 1.9 (release notes), so you'll need to upgrade in order to use JSONField

Sign up to request clarification or add additional context in comments.

2 Comments

I needed to update project in production, so I'll have to update django version there as well? There is no way to stay on 1.8?
Not if you want to use JSONField. It literally didn't exist before 1.9. If your project has a requirements.txt file that it builds from, you should be able to just update the version number in there.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.