filter for tag
This commit is contained in:
parent
f3f06fcf09
commit
7de6043861
|
|
@ -12,8 +12,6 @@ class Command(BaseCommand):
|
|||
|
||||
existing_establishment = Establishment.objects.filter(
|
||||
old_id__isnull=False
|
||||
).filter(
|
||||
tags__isnull=True
|
||||
)
|
||||
ESTABLISHMENT = 1
|
||||
SHOP = 2
|
||||
|
|
@ -56,7 +54,9 @@ class Command(BaseCommand):
|
|||
|
||||
# create Tag
|
||||
for tag in key_value.metadata_set.filter(
|
||||
establishment__id__in=list(existing_establishment.values_list('old_id', flat=True))):
|
||||
establishment__id__in=list(
|
||||
existing_establishment.values_list('old_id', flat=True)
|
||||
)):
|
||||
|
||||
new_tag, _ = Tag.objects.get_or_create(
|
||||
label={
|
||||
|
|
@ -67,7 +67,8 @@ class Command(BaseCommand):
|
|||
value=tag.value,
|
||||
category=tag_category,
|
||||
)
|
||||
est = existing_establishment.get(old_id=tag.establishment_id)
|
||||
est.tags.add(new_tag)
|
||||
est.save()
|
||||
|
||||
est = existing_establishment.filter(
|
||||
old_id=tag.establishment_id, tags__isnull=True).first()
|
||||
if est:
|
||||
est.tags.add(new_tag)
|
||||
est.save()
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user