Skip to content

Commit

Permalink
Fix DELETE call query params (#763)
Browse files Browse the repository at this point in the history
  • Loading branch information
aminalaee authored May 13, 2024
1 parent 9b1eff0 commit a60ccb1
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions sqladmin/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,14 +16,14 @@
cast,
no_type_check,
)
from urllib.parse import urljoin
from urllib.parse import parse_qsl, urljoin

from jinja2 import ChoiceLoader, FileSystemLoader, PackageLoader
from sqlalchemy.engine import Engine
from sqlalchemy.ext.asyncio import AsyncSession
from sqlalchemy.orm import Session, sessionmaker
from starlette.applications import Starlette
from starlette.datastructures import URL, FormData, UploadFile
from starlette.datastructures import URL, FormData, MultiDict, UploadFile
from starlette.exceptions import HTTPException
from starlette.middleware import Middleware
from starlette.requests import Request
Expand Down Expand Up @@ -493,7 +493,11 @@ async def delete(self, request: Request) -> Response:

await model_view.delete_model(request, pk)

return Response(content=str(request.url_for("admin:list", identity=identity)))
referer_url = URL(request.headers.get("referer", ""))
referer_params = MultiDict(parse_qsl(referer_url.query))
url = URL(str(request.url_for("admin:list", identity=identity)))
url = url.include_query_params(**referer_params)
return Response(content=str(url))

@login_required
async def create(self, request: Request) -> Response:
Expand Down

0 comments on commit a60ccb1

Please sign in to comment.