add review priority command start
This commit is contained in:
parent
2cca32e4cf
commit
9c59052e0b
0
apps/review/management/__init__.py
Normal file
0
apps/review/management/__init__.py
Normal file
0
apps/review/management/commands/__init__.py
Normal file
0
apps/review/management/commands/__init__.py
Normal file
24
apps/review/management/commands/add_review_priority.py
Normal file
24
apps/review/management/commands/add_review_priority.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
from django.core.management.base import BaseCommand
|
||||
from tqdm import tqdm
|
||||
|
||||
from review.models import Review
|
||||
from transfer.models import Reviews
|
||||
|
||||
|
||||
class Command(BaseCommand):
|
||||
help = '''Add review priority from old db to new db.'''
|
||||
|
||||
def handle(self, *args, **kwargs):
|
||||
reviews = Review.objects.all().values_list('old_id', flat=True)
|
||||
queryset = Reviews.objects.exclude(product_id__isnull=False).filter(
|
||||
id__in=list(reviews),
|
||||
).values_list('id', 'priority')
|
||||
|
||||
for old_id, priority in tqdm(queryset, desc='Add priority to reviews'):
|
||||
review = Review.objects.filter(old_id=old_id).first()
|
||||
if review:
|
||||
print(priority)
|
||||
|
||||
self.stdout.write(self.style.WARNING(f'Priority added to review objects.'))
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user