Opened 14 years ago
Closed 11 years ago
#15176 closed New feature (fixed)
History view of AdminSite doesn't take in account user defined queryset
Reported by: | Tetsuya Morimoto | Owned by: | nobody |
---|---|---|---|
Component: | contrib.admin | Version: | 1.2 |
Severity: | Normal | Keywords: | multi-db |
Cc: | info@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | yes | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
I found a bug which does not show history view in AdminSite when I defined a queryset for multi-db.
The history_view method of django.contrib.admin.ModelAdmin give a model object to get_object_or_404 as an argument. In that case, normal queryset of the model is used even if user defined custom queryset for the model. It means that the history view isn't showed for multi-db since it define custom queryset.
I made a patch, but I have no idea for making tests code. I only tested after I did some table operation, and I confirmed the history view.
Additionally, you might wonder about the LogEntry(django_admin_log). I think it's no problem since I can handle LogEntry to read/write with db-router.
Attachments (1)
Change History (11)
by , 14 years ago
Attachment: | get_history_view_with_user_defined_queryset.patch added |
---|
comment:1 by , 14 years ago
Component: | ORM aggregation → django.contrib.admin |
---|---|
Needs tests: | set |
Owner: | set to |
Triage Stage: | Unreviewed → Accepted |
comment:2 by , 14 years ago
I actually feel divided about this. The history is supposed to show all the things that have been changed/added/deleted in the past. Using a custom queryset means that the history may change over time, which seem kind of weird. I do recognise that there might be cases where we do want a custom queryset to be used, but I also think that in some other cases we might actually want the default one to be used. So I'd be in favour of a more granular system for the history view.
comment:4 by , 14 years ago
Severity: | → Normal |
---|---|
Type: | → New feature |
comment:13 by , 12 years ago
I think there might be an other case where it is expected that history_view
is using the custom queryset
set by the user. I'm currently working on an app where users can only see a subset of data in the admin depending on the groups they are in. By creating a custom queryset
method on the ModelAdmin
, this works great for listing and editing and I was expected that this would work for history as well (since the history button is visible on item level). However, the user has access to the history of all the items by changing the id in the url.
comment:14 by , 12 years ago
Cc: | added |
---|
comment:15 by , 11 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
This was fixed as part of #21013.
Patch to use self.queryset instead of model