本文整理汇总了Python中models.Topic.updated方法的典型用法代码示例。如果您正苦于以下问题:Python Topic.updated方法的具体用法?Python Topic.updated怎么用?Python Topic.updated使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Topic
的用法示例。
在下文中一共展示了Topic.updated方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: convert_topics
# 需要导入模块: from models import Topic [as 别名]
# 或者: from models.Topic import updated [as 别名]
def convert_topics(self, board_id=181):
start_time = time.time()
cursor = connection.cursor()
cursor.execute("SELECT * FROM smf_topics WHERE id_board=%s;" % board_id)
rows = cursor.fetchall()
for row in rows:
try:
try:
profile = Profile.objects.get(old_user_id=row[5])
except Profile.DoesNotExist, e:
if not row[5] == 0:
print "Profile does not exist. No big. -- %s" % row[5]
profile = None
forum = Forum.objects.get(old_forum_id=row[2])
cursor2 = connection.cursor()
cursor2.execute("select subject FROM smf_messages WHERE id_topic=%s ORDER BY id_msg ASC LIMIT 1" % row[0])
message = cursor2.fetchone()
sticky = False
if row[1] == 1:
sticky = True
topic = Topic()
if profile == None:
topic.user = None
else:
topic.user = profile.user
topic.old_poll_id = row[7]
topic.forum = forum
topic.name = message[0]
topic.old_topic_id = row[0]
topic.sticky = sticky
topic.forum = Forum.objects.get(old_forum_id=row[2])
topic.updated = datetime.now()
topic.views = row[9]
topic.save()
except Exception, e:
with open("conversion_errors.log", "a") as myfile:
myfile.write("%s - %s \r\n %s\r\n\r\n" % (row[0], row[1], str(e)))