better admin experience

This commit is contained in:
Ethan Roseman 2022-08-24 10:35:16 +09:00
parent 9848c8db9a
commit 3defb09002
No known key found for this signature in database
GPG Key ID: 27F9FCEB8E4969BD
4 changed files with 57 additions and 4 deletions

View File

@ -1,9 +1,26 @@
from django.contrib import admin from django.contrib import admin
import nested_admin
from frog_api.models import Category, Entry, Measure, Project, Version from frog_api.models import Category, Entry, Measure, Project, Version
admin.site.register(Project)
admin.site.register(Version) class CategoryInline(nested_admin.NestedStackedInline):
admin.site.register(Category) model = Category
extra = 0
class VersionInline(nested_admin.NestedStackedInline):
model = Version
inlines = [CategoryInline]
extra = 0
class ProjectAdmin(nested_admin.NestedModelAdmin):
model = Project
inlines = [VersionInline]
extra = 0
admin.site.register(Project, ProjectAdmin)
admin.site.register(Entry) admin.site.register(Entry)
admin.site.register(Measure) admin.site.register(Measure)

View File

@ -39,6 +39,7 @@ INSTALLED_APPS = [
"django.contrib.staticfiles", "django.contrib.staticfiles",
"rest_framework", "rest_framework",
"frog_api", "frog_api",
"nested_admin",
] ]
MIDDLEWARE = [ MIDDLEWARE = [

36
poetry.lock generated
View File

@ -123,6 +123,18 @@ tzdata = {version = "*", markers = "sys_platform == \"win32\""}
argon2 = ["argon2-cffi (>=19.1.0)"] argon2 = ["argon2-cffi (>=19.1.0)"]
bcrypt = ["bcrypt"] bcrypt = ["bcrypt"]
[[package]]
name = "django-nested-admin"
version = "3.4.0"
description = "Django admin classes that allow for nested inlines"
category = "main"
optional = false
python-versions = "*"
[package.dependencies]
python-monkey-business = ">=1.0.0"
six = "*"
[[package]] [[package]]
name = "django-stubs" name = "django-stubs"
version = "1.12.0" version = "1.12.0"
@ -280,6 +292,17 @@ category = "main"
optional = false optional = false
python-versions = ">=3.6" python-versions = ">=3.6"
[[package]]
name = "python-monkey-business"
version = "1.0.0"
description = "Utility functions for monkey-patching python code"
category = "main"
optional = false
python-versions = "*"
[package.dependencies]
six = ">=1.7.0"
[[package]] [[package]]
name = "pytz" name = "pytz"
version = "2022.2.1" version = "2022.2.1"
@ -306,6 +329,14 @@ urllib3 = ">=1.21.1,<1.27"
socks = ["PySocks (>=1.5.6,!=1.5.7)"] socks = ["PySocks (>=1.5.6,!=1.5.7)"]
use_chardet_on_py3 = ["chardet (>=3.0.2,<6)"] use_chardet_on_py3 = ["chardet (>=3.0.2,<6)"]
[[package]]
name = "six"
version = "1.16.0"
description = "Python 2 and 3 compatibility utilities"
category = "main"
optional = false
python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*"
[[package]] [[package]]
name = "sqlparse" name = "sqlparse"
version = "0.4.2" version = "0.4.2"
@ -405,7 +436,7 @@ socks = ["PySocks (>=1.5.6,!=1.5.7,<2.0)"]
[metadata] [metadata]
lock-version = "1.1" lock-version = "1.1"
python-versions = "^3.8" python-versions = "^3.8"
content-hash = "d6d249d7343a25a3c0cb3fe28f04c35d9872709f2e1141dc26210ca8e090bb66" content-hash = "0dbaf47574a3614ffc93deed76368770fd42f98f9893e82da65b5c106b7d793c"
[metadata.files] [metadata.files]
asgiref = [ asgiref = [
@ -463,6 +494,7 @@ coreschema = [
{file = "coreschema-0.0.4.tar.gz", hash = "sha256:9503506007d482ab0867ba14724b93c18a33b22b6d19fb419ef2d239dd4a1607"}, {file = "coreschema-0.0.4.tar.gz", hash = "sha256:9503506007d482ab0867ba14724b93c18a33b22b6d19fb419ef2d239dd4a1607"},
] ]
django = [] django = []
django-nested-admin = []
django-stubs = [] django-stubs = []
django-stubs-ext = [] django-stubs-ext = []
djangorestframework = [ djangorestframework = [
@ -598,11 +630,13 @@ psycopg2-binary = [
{file = "psycopg2_binary-2.9.3-cp39-cp39-win32.whl", hash = "sha256:46f0e0a6b5fa5851bbd9ab1bc805eef362d3a230fbdfbc209f4a236d0a7a990d"}, {file = "psycopg2_binary-2.9.3-cp39-cp39-win32.whl", hash = "sha256:46f0e0a6b5fa5851bbd9ab1bc805eef362d3a230fbdfbc209f4a236d0a7a990d"},
{file = "psycopg2_binary-2.9.3-cp39-cp39-win_amd64.whl", hash = "sha256:accfe7e982411da3178ec690baaceaad3c278652998b2c45828aaac66cd8285f"}, {file = "psycopg2_binary-2.9.3-cp39-cp39-win_amd64.whl", hash = "sha256:accfe7e982411da3178ec690baaceaad3c278652998b2c45828aaac66cd8285f"},
] ]
python-monkey-business = []
pytz = [] pytz = []
requests = [ requests = [
{file = "requests-2.28.1-py3-none-any.whl", hash = "sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349"}, {file = "requests-2.28.1-py3-none-any.whl", hash = "sha256:8fefa2a1a1365bf5520aac41836fbee479da67864514bdb821f31ce07ce65349"},
{file = "requests-2.28.1.tar.gz", hash = "sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983"}, {file = "requests-2.28.1.tar.gz", hash = "sha256:7c5599b102feddaa661c826c56ab4fee28bfd17f5abca1ebbe3e7f19d7c97983"},
] ]
six = []
sqlparse = [ sqlparse = [
{file = "sqlparse-0.4.2-py3-none-any.whl", hash = "sha256:48719e356bb8b42991bdbb1e8b83223757b93789c00910a616a071910ca4a64d"}, {file = "sqlparse-0.4.2-py3-none-any.whl", hash = "sha256:48719e356bb8b42991bdbb1e8b83223757b93789c00910a616a071910ca4a64d"},
{file = "sqlparse-0.4.2.tar.gz", hash = "sha256:0c00730c74263a94e5a9919ade150dfc3b19c574389985446148402998287dae"}, {file = "sqlparse-0.4.2.tar.gz", hash = "sha256:0c00730c74263a94e5a9919ade150dfc3b19c574389985446148402998287dae"},

View File

@ -10,6 +10,7 @@ python = "^3.8"
Django = "^4.1" Django = "^4.1"
djangorestframework = "^3.13.1" djangorestframework = "^3.13.1"
psycopg2-binary = "^2.9.3" psycopg2-binary = "^2.9.3"
django-nested-admin = "^3.4.0"
[tool.poetry.dev-dependencies] [tool.poetry.dev-dependencies]
black = "^22.6.0" black = "^22.6.0"