You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 

32 lines
1.5 KiB

# backend/apps/hadis/management/commands/populate_narrator_links.py
from django.core.management.base import BaseCommand
from apps.hadis.models import HadisCorrection, HadisInterpretation
class Command(BaseCommand):
help = 'Populates the default narrator and links for all existing Corrections and Interpretations.'
def handle(self, *args, **options):
self.stdout.write(self.style.WARNING("Updating default values for narrator and links..."))
default_narrator = "زُرارَةُ بْنُ أَعْيَنَ الشَّيبانِيّ"
default_links = [
{"title": "Первая ссылка Первая ссылка ссылкассы...", "link": "google.com"},
{"title": "Первая ссылка.", "link": "google.com"},
{"title": "Первая ссылка.", "link": "google.com"}
]
# آپدیت تمام رکوردهای جدول تصحیحات
corr_count = HadisCorrection.objects.all().update(
narrator=default_narrator,
links=default_links
)
# آپدیت تمام رکوردهای جدول تفاسیر
interp_count = HadisInterpretation.objects.all().update(
narrator=default_narrator,
links=default_links
)
self.stdout.write(self.style.SUCCESS(f"✅ Successfully updated {corr_count} HadisCorrections!"))
self.stdout.write(self.style.SUCCESS(f"✅ Successfully updated {interp_count} HadisInterpretations!"))