本文整理汇总了Python中models.Exercise.save方法的典型用法代码示例。如果您正苦于以下问题:Python Exercise.save方法的具体用法?Python Exercise.save怎么用?Python Exercise.save使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Exercise
的用法示例。
在下文中一共展示了Exercise.save方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_csv
# 需要导入模块: from models import Exercise [as 别名]
# 或者: from models.Exercise import save [as 别名]
def load_csv(self):
# import codecs
# reader = codecs.getreader('utf-8')
reader = csv.reader(open('./data/base_ex_women.csv', 'r'))
print(repr(reader))
print(dir(reader))
try:
i = True
while True:
row = reader.next()
row = [unicode(s, "utf-8") for s in row]
# for row in reader.next():
if i:
i = False
continue
logging.error(row)
c = Exercise()
# row = map(str, row)
row = row + ([''] * 5)
logging.error(row)
c.title = row[0]
c.description = row[1]
c.image_link = row[2]
c.link_to = row[3]
c.video_link = row[4]
c.for_women = True
c.save()
except Exception, e:
pass
示例2: submit_exercise
# 需要导入模块: from models import Exercise [as 别名]
# 或者: from models.Exercise import save [as 别名]
def submit_exercise(self, title, description, content):
exercise = Exercise(title=title, description=description, content=content)
exercise.save()
return True