Opened 17 years ago
Closed 17 years ago
#7113 closed (fixed)
The `ChangeList` does not support custom queryset subclasses
Reported by: | jbronn | Owned by: | Malcolm Tredinnick |
---|---|---|---|
Component: | contrib.admin | Version: | dev |
Severity: | Keywords: | admin changelist queryset custom | |
Cc: | andrew@… | Triage Stage: | Accepted |
Has patch: | yes | Needs documentation: | no |
Needs tests: | no | Patch needs improvement: | no |
Easy pickings: | no | UI/UX: | no |
Description
Custom QuerySet
classes (like GeoDjango's GeoQuerySet
) can't be merged with regular QuerySet
objects (using |
, &
operators). This problem manifests itself when trying to use search fields with a model that uses a QuerySet
subclass:
TypeError ... Cannot merge querysets of different types ('GeoQuerySet' and 'QuerySet'.
The root cause is that ChangeList
hard-codes using QuerySet for the search fields.
In my patch ChangeList
takes advantage of existing information to determine the type of queryset being used and store it in a root_query_set_class
attribute that is used when performing searches.
Attachments (1)
Change History (7)
by , 17 years ago
Attachment: | changelist_custom_qs.diff added |
---|
comment:1 by , 17 years ago
Summary: | The `ChangeList` does not support custom queryset classes → The `ChangeList` does not support custom queryset subclasses |
---|
comment:2 by , 17 years ago
Triage Stage: | Unreviewed → Accepted |
---|---|
Version: | newforms-admin → SVN |
This looks right to me, but I think this should be applied to trunk first and then merged over to newforms-admin since this code isn't being directly modified in newforms-admin. Otherwise I'd apply this.
comment:3 by , 17 years ago
Owner: | changed from | to
---|
comment:4 by , 17 years ago
I think you're fixing the symptom, rather than the root problem, with this patch. The problem with the fix here is that it's only the tip of the iceberg. Every single reusable app that uses a QuerySet
will have to write similarly awkward code.
The real issue is the tighter restrictions on QuerySet
combinations, which has gone a little overboard. The idea behind that change was to prevent people doing silly things like trying to merge a QuerySet
and a ValuesQuerySet
(which I saw attempted in a post to django-users), not to prevent sensible merges. I didn't think of all the consequences at the time.The problem with the fix here is that it's only the tip of the iceberg. Every single reusable app that uses a QuerySet
will have to write similarly awkward code.
I'll rethink the sanity check and possibly remove it entirely (leading to more "GIGO" behaviour) if there's nothing better.
comment:5 by , 17 years ago
Cc: | added |
---|
comment:6 by , 17 years ago
Resolution: | → fixed |
---|---|
Status: | new → closed |
Fixed in [7742] (by removing the overly-strict error checking).
Allows for custom querysets in the admin changelist.