Edited polymorphic/query_translate.py via GitHub
parent
6f8e31222d
commit
30f11a35d7
|
|
@ -123,7 +123,8 @@ def translate_polymorphic_field_path(queryset_model, field_path):
|
||||||
Returns: translated path (unchanged, if no translation needed)
|
Returns: translated path (unchanged, if no translation needed)
|
||||||
"""
|
"""
|
||||||
classname, sep, pure_field_path = compat_partition(field_path, '___')
|
classname, sep, pure_field_path = compat_partition(field_path, '___')
|
||||||
if not sep: return field_path
|
if not sep:
|
||||||
|
return field_path
|
||||||
assert classname, 'PolymorphicModel: %s: bad field specification' % field_path
|
assert classname, 'PolymorphicModel: %s: bad field specification' % field_path
|
||||||
|
|
||||||
negated = False
|
negated = False
|
||||||
|
|
@ -173,16 +174,20 @@ def translate_polymorphic_field_path(queryset_model, field_path):
|
||||||
if b == baseclass:
|
if b == baseclass:
|
||||||
return myclass.__name__.lower()
|
return myclass.__name__.lower()
|
||||||
path = _create_base_path(baseclass, b)
|
path = _create_base_path(baseclass, b)
|
||||||
if path: return path + '__' + myclass.__name__.lower()
|
if path:
|
||||||
|
return path + '__' + myclass.__name__.lower()
|
||||||
return ''
|
return ''
|
||||||
|
|
||||||
basepath = _create_base_path(queryset_model, model)
|
basepath = _create_base_path(queryset_model, model)
|
||||||
|
|
||||||
if negated: newpath = '-'
|
if negated:
|
||||||
else: newpath = ''
|
newpath = '-'
|
||||||
|
else:
|
||||||
|
newpath = ''
|
||||||
|
|
||||||
newpath += basepath
|
newpath += basepath
|
||||||
if basepath: newpath += '__'
|
if basepath:
|
||||||
|
newpath += '__'
|
||||||
|
|
||||||
newpath += pure_field_path
|
newpath += pure_field_path
|
||||||
return newpath
|
return newpath
|
||||||
|
|
@ -201,7 +206,8 @@ def _create_model_filter_Q(modellist, not_instance_of=False):
|
||||||
be needed.
|
be needed.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
if not modellist: return None
|
if not modellist:
|
||||||
|
return None
|
||||||
|
|
||||||
from polymorphic_model import PolymorphicModel
|
from polymorphic_model import PolymorphicModel
|
||||||
|
|
||||||
|
|
@ -220,6 +226,7 @@ def _create_model_filter_Q(modellist, not_instance_of=False):
|
||||||
qlist = [ q_class_with_subclasses(m) for m in modellist ]
|
qlist = [ q_class_with_subclasses(m) for m in modellist ]
|
||||||
|
|
||||||
q_ored = reduce(lambda a, b: a | b, qlist)
|
q_ored = reduce(lambda a, b: a | b, qlist)
|
||||||
if not_instance_of: q_ored = ~q_ored
|
if not_instance_of:
|
||||||
|
q_ored = ~q_ored
|
||||||
return q_ored
|
return q_ored
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue