jmrivas86 / django-json-widget

An alternative widget that makes it easy to edit the new Django's field JSONField (PostgreSQL specific model fields)
MIT License
440 stars 88 forks source link

Change README instructions for django 3.1 #44

Closed dadokkio closed 3 years ago

dadokkio commented 4 years ago

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 4 years ago

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

StevenMapes commented 3 years ago

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+

jmrivas86 commented 3 years ago

Fixed in the new versions with PR #46