Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix DELETE call query params #763

Merged
merged 2 commits into from
May 13, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading