模板层(template) 你可能已经注意到我们在例子视图中返回文本的方式有点特别. 也就是说,HTML被直接硬编码在 Python代码之中. 1 2 3 4 def current_datetime(request): now = datetime.datetime.now() html = "<html><body>It is now %s.</body></html>" % now return HttpRe…
>>> from django.template import Template >>> t = Template("My name is {{ my_name }}.") Traceback (most recent call last): File "C:\Python33\lib\site-packages\django\conf\__init__.py", line 38, in _setup settings…
链表操作 链表,就是一张表的外键字段,连接另外一张表的主键字段 一对多 models.ForeignKey()外键字段一对多,值是要外键的表类 from __future__ import unicode_literals from django.db import models #导入models对象 class yong_hu_shen_fen(models.Model): #创建用户是否表类 id = models.AutoField('id',primary_key=True) #自增i…