#coding:utf-8
from django.core.management import BaseCommand
from talos.models.topic.topic import *
import json


class Command(BaseCommand):
    def handle(self, *args, **options):
        print 'get topic info start!'
        # 发布术后日记帖
        with open('topic_infos.txt', 'wb') as f:
            topics = Problem.objects.filter(answer__isnull=False)
            for topic in topics:
                print topic.id
                try:
                    f.write(topic.answer)
                    f.write('\n')
                except:
                    continue

        print 'done'



