Skip to content

Commit

Permalink
add json viewer in admin (#66)
Browse files Browse the repository at this point in the history
  • Loading branch information
amineau authored Oct 18, 2023
1 parent efa8777 commit d618ce9
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 1 deletion.
1 change: 1 addition & 0 deletions platform_back/settings/admin/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
"django.contrib.admin",
"django.contrib.messages",
"django.contrib.admindocs",
"django_json_widget",
]

MIDDLEWARE += [
Expand Down
27 changes: 26 additions & 1 deletion poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ python-dotenv = "^0.17.0"
requests = "^2.28.2"
whitenoise = "^5.3.0"
django-cron = "^0.6.0"
django-json-widget = "^1.1.1"

[tool.poetry.group.deploy]
optional = true
Expand Down
5 changes: 5 additions & 0 deletions user/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
# file that was distributed with this source code.
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from django.db import models
from django_json_widget.widgets import JSONEditorWidget

from user.models import GuidedTour
from user.models import Notification
Expand All @@ -30,6 +32,9 @@ class GuidedTourAdmin(admin.ModelAdmin):

@admin.register(Notification)
class NotificationAdmin(admin.ModelAdmin):
formfield_overrides = {
models.JSONField: {"widget": JSONEditorWidget},
}
list_display = ("user", "cloud_id", "event", "event_type", "consumed", "created_at")
list_filter = (
"event_type",
Expand Down

0 comments on commit d618ce9

Please sign in to comment.