angrykola

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理

2013年11月14日

摘要: 加载模板:使用django提哦那个的API,首先将模板的保存位置告诉框架, 设置settings.py。#settings.pyTEMPLATE_DIRS = ( ... "D:/web/mysite/templates", #注意在python中是使用反斜杠“/”)第二部:修改视图文件 1 #views.py 2 from django.template.loader import get_template 3 from django.template import Context 4 from django.http import HttpResponse 5 impo 阅读全文
posted @ 2013-11-14 23:05 kolaman 阅读(179) 评论(0) 推荐(0)

摘要: 抽象超类:>>> class Super(): #建立一个抽象超类 def display(self): self.action() def action(self): #这是一个抽象方法 raise NotImplementedError('aciton must be defined') #raise强制抛出异常>>> class Subclass(Super): #建立子类,并且补全抽象方法 def action(self): print('This is Subclass') >>> test ... 阅读全文
posted @ 2013-11-14 21:14 kolaman 阅读(559) 评论(0) 推荐(0)