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

Paginator for raw_id_fields popup returns 404 #420

Open
stefanofusai opened this issue Jan 21, 2025 · 5 comments
Open

Paginator for raw_id_fields popup returns 404 #420

stefanofusai opened this issue Jan 21, 2025 · 5 comments
Assignees
Labels
bug Something isn't working

Comments

@stefanofusai
Copy link

Python version
3.13

Django version
5.1.4

Package version
0.29.3

Current behavior (bug description)

Image

When opening the popup for a related model (defined in the admin class via the raw_id_fields var) and trying to navigate through the pages of the related model, clicking on any page returns 404

Image

The html for the paginator is as follows:

<p class="paginator">

    <span class="this-page">1</span> 

    <a href="?_popup=1&amp;_to_field=id&amp;p=2">2</a> 

    <a href="?_popup=1&amp;_to_field=id&amp;p=3">3</a> 

    <a href="?_popup=1&amp;_to_field=id&amp;p=4">4</a> 

    <a href="?_popup=1&amp;_to_field=id&amp;p=5" class="end">5</a> 

</p>

But upon clicking any of these links, the following error appears:

Image

From my understanding the href isn't being concatenated to the popup URL, but I'm unsure what the cause is

Expected behavior
Pagination for popups of related models works fine

@stefanofusai stefanofusai added the bug Something isn't working label Jan 21, 2025
@fabiocaccamo fabiocaccamo moved this to Todo in Open Source Jan 21, 2025
@fabiocaccamo
Copy link
Owner

@stefanofusai could you share your project (remove all the unnecessary parts) so I can debug the problem quickly?

@stefanofusai
Copy link
Author

@fabiocaccamo the project is quite big (and private) so it's pretty hard to share it. Maybe we could schedule a call and I could show it to you?

Anyhow here's a minimal repro of a model breaking:

@admin.register(User)
class UserAdmin(BaseUserAdmin):
    pass

@admin.register(UserProfile)
class UserProfileAdmin(admin.ModelAdmin):
    raw_id_fields = ("user",)

@fabiocaccamo
Copy link
Owner

@stefanofusai ok don't worry, I'll replicate the problem myself as soon as I have time.

@fabiocaccamo
Copy link
Owner

fabiocaccamo commented Jan 31, 2025

@stefanofusai I think this issue might be caused by the {% querystring %} template tag introduced in Django 4.0.

Could you please check if the problem still occurs when this library is not used?

@stefanofusai
Copy link
Author

stefanofusai commented Jan 31, 2025

@fabiocaccamo I can confirm that not using this library (and therefore using the standard Django admin) works fine; the popup redirects first to http://localhost:8000/admin/myapp/mymodel/?_to_field=id&_popup=1 and the second page to http://localhost:8000/admin/myapp/mymodel/?_popup=1&_to_field=id&p=2

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
Status: Todo
Development

No branches or pull requests

2 participants