From e3775e046957163514477bb8a1712b208be4dbb4 Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Wed, 8 Nov 2023 15:37:25 +0100 Subject: [PATCH 1/2] Change pk converter in routes --- sqladmin/application.py | 4 ++-- sqladmin/helpers.py | 6 ------ 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/sqladmin/application.py b/sqladmin/application.py index 88ccabe5..bbe6a92e 100644 --- a/sqladmin/application.py +++ b/sqladmin/application.py @@ -385,7 +385,7 @@ def __init__( Mount("/statics", app=statics, name="statics"), Route("/", endpoint=self.index, name="index"), Route("/{identity}/list", endpoint=self.list, name="list"), - Route("/{identity}/details/{pk}", endpoint=self.details, name="details"), + Route("/{identity}/details/{pk:path}", endpoint=self.details, name="details"), Route( "/{identity}/delete", endpoint=self.delete, @@ -399,7 +399,7 @@ def __init__( methods=["GET", "POST"], ), Route( - "/{identity}/edit/{pk}", + "/{identity}/edit/{pk:path}", endpoint=self.edit, name="edit", methods=["GET", "POST"], diff --git a/sqladmin/helpers.py b/sqladmin/helpers.py index 16044d5e..072ecf74 100644 --- a/sqladmin/helpers.py +++ b/sqladmin/helpers.py @@ -174,12 +174,6 @@ def stream_to_csv( return callback(writer) # type: ignore -def get_primary_key(model: type) -> Column: - pks = inspect(model).mapper.primary_key - assert len(pks) == 1, "Multiple Primary Keys not supported." - return pks[0] - - def get_primary_keys(model: Any) -> Tuple[Column, ...]: return tuple(inspect(model).mapper.primary_key) From 04999a3dfb19b15dee8695b1c76fe974ca65267c Mon Sep 17 00:00:00 2001 From: Amin Alaee Date: Thu, 9 Nov 2023 11:36:38 +0100 Subject: [PATCH 2/2] fix formatting --- sqladmin/application.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sqladmin/application.py b/sqladmin/application.py index bbe6a92e..c06f0049 100644 --- a/sqladmin/application.py +++ b/sqladmin/application.py @@ -385,7 +385,9 @@ def __init__( Mount("/statics", app=statics, name="statics"), Route("/", endpoint=self.index, name="index"), Route("/{identity}/list", endpoint=self.list, name="list"), - Route("/{identity}/details/{pk:path}", endpoint=self.details, name="details"), + Route( + "/{identity}/details/{pk:path}", endpoint=self.details, name="details" + ), Route( "/{identity}/delete", endpoint=self.delete,