first commit

This commit is contained in:
Beyhan Oğur
2026-04-26 22:27:56 +03:00
commit d9f1ea341e
1021 changed files with 70645 additions and 0 deletions

View File

@@ -0,0 +1,38 @@
from django.core.management.base import BaseCommand
from blog.models import Post
class Command(BaseCommand):
help = 'Tüm blog postları için eksik thumb dosyalarını oluşturur'
def handle(self, *args, **options):
posts = Post.objects.filter(image__isnull=False)
total = posts.count()
created = 0
skipped = 0
self.stdout.write(f'\n{total} post kontrol ediliyor...\n')
for post in posts:
if not post.thumb:
try:
post.save() # save() metodu thumb'ı otomatik oluşturacak
created += 1
self.stdout.write(
self.style.SUCCESS(f'✓ Thumb oluşturuldu: {post.title}')
)
except Exception as e:
self.stdout.write(
self.style.ERROR(f'✗ Hata ({post.title}): {str(e)}')
)
else:
skipped += 1
self.stdout.write(
self.style.WARNING(f'- Atlandı (zaten var): {post.title}')
)
self.stdout.write(
self.style.SUCCESS(
f'\n✓ Tamamlandı! {created} thumb oluşturuldu, {skipped} atlandı.\n'
)
)