Related: #6903
--
Ticket URL: <https://code.djangoproject.com/ticket/21795>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
@honyczek it works for me, both in production (uWSGI behind a Nginx
reverse proxy) and with the dev server using various combinations of hosts
and ports.
Would you be able to upload a minimal project that demonstrates the issue?
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:1>
Comment (by honyczek):
There is one of my projects, where I enabled preserve_filters, which is
available to public. http://confiback.sourceforge.net/
I'll try it at Nginx. But at Apache with mod_wsgi it doesn't work. Python
2.7.3/Django 1.6 or Python 2.7.5/Django 1.6
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:2>
* status: new => closed
* resolution: => needsinfo
Comment:
@honyczek, it would be really helpful if you could do some more
investigation yourself and provide some more details to reproduce the
problem. Just saying it "doesn't work" is not a great bug report.
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:3>
Comment (by honyczek):
If I enable preserve_filters parameter in my
django.contrib.admin.ModelAdmin instance:
{{{
class DeviceAdmin(admin.ModelAdmin):
list_display = ['name', 'ip', 'profileUrl', 'backupsUrl', 'linkUrl']
list_filter = ['profile']
inlines = [KeywordMacroInline]
actions_on_bottom = True
actions_on_top = False
actions = ['manual_backup']
preserve_filters = True
def linkUrl(self, device):
if device.url:
return "<a href=\"%s\" target=\"_blank\">%s</a>" % (device.url,
_("Click to view device custom URL"))
else:
return "<a>-</a>"
linkUrl.allow_tags = True
linkUrl.short_description = _("Custom URL")
def profileUrl(self, device):
return "<a href=\"%s\">%s</a>" %
(urlresolvers.reverse('admin:frontend_profile_change',
args=(device.profile.id,)),device.profile.name)
profileUrl.allow_tags = True
profileUrl.short_description = _("Profile")
def backupsUrl(self, device):
return "<a href=\"%s?device__id__exact=%s\">%s: %s</a> (<a
href=\"%s\">%s</a>)" %
(urlresolvers.reverse('admin:frontend_backup_changelist'), device.id,
_("Total"), models.Backup.objects.filter(device=device).count(),
urlresolvers.reverse('frontend:download_backup_as_file',
kwargs={'backup_id':
models.Backup.objects.filter(device=device).latest('date').id}),
_("Download the latest"))
backupsUrl.allow_tags = True
backupsUrl.short_description = _("Backups")
def manual_backup(modeladmin, request, queryset):
from django.shortcuts import redirect
_ret =
"{}?ids={}".format(urlresolvers.reverse('frontend:run_backup'),"_".join(str(i.id)
for i in queryset))
return redirect(_ret)
manual_backup.short_description = _("Make manual backup of selected
devices")
}}}
then I select one of profiles on the right menu to filter list, then open
one Device to edit details and then I click to Save button, so Admin
returns to Device list with clean filter and displays devices from all
profiles (profile filter is empty and All is selected).
What I expect:
After click to Save button, Admin returns to Device list and filter will
be still enabled (previously selected profile will remain selected).
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:4>
* status: closed => new
* resolution: needsinfo =>
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:5>
Comment (by timo):
Is `_changelist_filters` being dropped from the query string?
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:6>
Comment (by honyczek):
No, on edit form I have URL:
{{{http://server/confiback/admin/frontend/device/89/?_changelist_filters=e%3D1}}}
and after saving it returns to list with URL:
{{{http://server/confiback/admin/frontend/device/?e=1}}}. But filter is
not applied.
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:7>
Comment (by timo):
It looks like the `changelist_view` function in contrib.admin.options is
throwing an `IncorrectLookupParameters` exception. It would be great if
you could look into the reason for that. I think the fact that you say it
worked on localhost not on other servers is a red herring.
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:8>
* status: new => closed
* resolution: => needsinfo
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:9>
Comment (by anonymous):
Ok, I'd like to do it, but I haven't any knowledge how to debug this.
Could you give me some recommendations what to use and where to look?
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:10>
Comment (by honyczek):
Ok, I'd like to do it, but I haven't any knowledge how to debug this.
Could you give me some recommendations what to use and where to look?
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:11>
Comment (by timo):
Ping me (timograham) in #django-dev if you like, it will be easier than
communicating via this ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:12>
* status: closed => new
* ui_ux: 1 => 0
* resolution: needsinfo =>
* stage: Unreviewed => Accepted
Comment:
We discussed this on #django-dev and determined that the problem is
specific to running a site with a URL prefix. In particular,
`add_preserved_filters` raises a `Resolver404`.
loic84 is looking into it further.
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:13>
Comment (by loic84):
@honyczek could you check if
https://github.com/loic/django/compare/ticket21795 fixes your issue?
I have a feeling writing a test for this patch is going to be pretty
painful.
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:14>
* cc: loic@… (added)
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:15>
* has_patch: 0 => 1
Comment:
PR https://github.com/django/django/pull/2493.
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:16>
* status: new => closed
* resolution: => fixed
Comment:
Great, it seems to be fixed. Thanks a lot.
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:17>
* status: closed => new
* resolution: fixed =>
Comment:
@honyczek did you test the patch on the pull request? because it's not
merged on master yet, hence why I'm reopening the ticket.
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:18>
* status: new => closed
* resolution: => fixed
Comment:
In [changeset:"4339e9a92d98371a50a6fe54ab7ea0c602ecee28"]:
{{{
#!CommitTicketReference repository=""
revision="4339e9a92d98371a50a6fe54ab7ea0c602ecee28"
Fixed #21795 -- Made add_preserved_filters account for url prefixes.
Thanks to trac username honyczek for the report. Refs #6903.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:19>
Comment (by Tim Graham <timograham@…>):
In [changeset:"5268d71f18d12c362d74010210309c1cec8e8a1a"]:
{{{
#!CommitTicketReference repository=""
revision="5268d71f18d12c362d74010210309c1cec8e8a1a"
[1.7.x] Fixed #21795 -- Made add_preserved_filters account for url
prefixes.
Thanks to trac username honyczek for the report. Refs #6903.
Backport of 4339e9a92d from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:21>
Comment (by Tim Graham <timograham@…>):
In [changeset:"a5297c1ef4c4c010d1eb979177d4633beb5f9cad"]:
{{{
#!CommitTicketReference repository=""
revision="a5297c1ef4c4c010d1eb979177d4633beb5f9cad"
[1.6.x] Fixed #21795 -- Made add_preserved_filters account for url
prefixes.
Thanks to trac username honyczek for the report. Refs #6903.
Backport of 4339e9a92d from master
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:20>
Comment (by honyczek):
Replying to [comment:18 loic84]:
> @honyczek did you test the patch on the pull request? because it's not
merged on master yet, hence why I'm reopening the ticket.
Yes, i did. Thanks.
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:22>
Comment (by loic84):
Cool, thanks @honyczek.
--
Ticket URL: <https://code.djangoproject.com/ticket/21795#comment:23>