managers: fix the for_tag() method
the Q object is not in the django.db.models package
This commit is contained in:
parent
a5a2356495
commit
0a90cc8f55
|
@ -1,10 +1,9 @@
|
|||
from django.contrib.contenttypes.models import ContentType
|
||||
from django.db.models.query import QuerySet
|
||||
from django.db.models import Q
|
||||
from django.core.cache import cache
|
||||
from model_utils.managers import PassThroughManager
|
||||
|
||||
import models
|
||||
|
||||
|
||||
JOURNAL_METADATA_CACHE_TIMEOUT = 3600
|
||||
|
||||
|
@ -70,6 +69,8 @@ class JournalQuerySet(QuerySet):
|
|||
'''Returns Journal records linked to this tag by their own tag or
|
||||
the tag on their data records.
|
||||
'''
|
||||
from . import models
|
||||
|
||||
if not isinstance(tag, models.Tag):
|
||||
try:
|
||||
tag = models.Tag.objects.get_cached(name=tag)
|
||||
|
@ -77,9 +78,9 @@ class JournalQuerySet(QuerySet):
|
|||
return self.none()
|
||||
# always remember: multiple join (OR in WHERE) produces duplicate
|
||||
# lines ! Use .distinct() for safety.
|
||||
return self.filter(models.Q(tag=tag)|
|
||||
models.Q(objectdata__tag=tag)|
|
||||
models.Q(stringdata__tag=tag)) \
|
||||
return self.filter(Q(tag=tag)|
|
||||
Q(objectdata__tag=tag)|
|
||||
Q(stringdata__tag=tag)) \
|
||||
.distinct()
|
||||
|
||||
|
||||
|
|
Loading…
Reference in New Issue