parent
b9f9c3801d
commit
60ece0c155
1 changed files with 14 additions and 0 deletions
@ -0,0 +1,14 @@ |
||||
from django.core.management.base import BaseCommand, CommandError |
||||
from theme.models import Theme, ThemeBlog |
||||
from article.models import Article |
||||
|
||||
|
||||
class Command(BaseCommand): |
||||
def handle(self, *args, **options): |
||||
for article in Article.objects.filter(type=Article.blog).prefetch_related('blog_theme'): |
||||
blogthemes = article.blog_theme.all().values_list('id', flat=True) |
||||
themes = Theme.objects.filter( |
||||
types=Theme.types.article, |
||||
blogtheme_linking_id__in=blogthemes) |
||||
article.theme.clear() |
||||
article.theme.add(*themes) |
||||
Loading…
Reference in new issue