jmrivas86/django-json-widget

Change README instructions for django 3.1

Closed this issue · 3 comments

  • django-json-widget version:1.0.1
  • Django version: 3.1
  • Python version: 3.8
  • Operating System: linux

Description

JSONField is now a standard field in django models so you can import that from models instead of importing fields from django.contrib.postgres

What I Did

Changed from:

from django.contrib import admin
from django.contrib.postgres import fields
from django_json_widget.widgets import JSONEditorWidget
from .models import YourModel

@admin.register(YourModel)
class YourModelAdmin(admin.ModelAdmin):
    formfield_overrides = {
        fields.JSONField: {'widget': JSONEditorWidget},
    }

to:

from django.contrib import admin
from django.db import models
from django_json_widget.widgets import JSONEditorWidget
from .models import YourModel

@admin.register(YourModel)
class YourModelAdmin(admin.ModelAdmin):
    formfield_overrides = {
        models.JSONField: {'widget': JSONEditorWidget},
    }
epoq commented

Thanks @dadokkio, it's work again now for me !

It should also be noted that futures is also no longer needed and can be removed from setup.py / requirements.txt along with the postgres requirement if Django is 3.1+

Fixed in the new versions with PR #46