摘要:
function getTableContent(node) { event.preventDefault(); var tr = node.parentNode.parentNode; var id_val = tr.cells[0].innerText; $.ajax({ url:'/delet 阅读全文
摘要:
1. 在现有基础上又添加一个表的时候migrate报错 migrate报错django.db.utils.OperationalError: (1050, "Table 'cmdb_eidc' already exists") 解决1:python manage.py migrate --fake cmdb python manage.py migrate 如上没有解决:继续下面 ... 阅读全文
摘要:
1.通过关键字dict和关键字参数创建 >>> dic = dict(spam = 1, egg = 2, bar =3) >>> dic {'bar': 3, 'egg': 2, 'spam': 1} 2.通过二元组列表创建 >>> list = [('spam', 1), ('egg', 2), ('bar', 3)] >>> dic = dict(list) >>> dic {'bar'. 阅读全文
摘要:
>>> l1=[1,2,3,4,5,6]>>> l2=[4,5,6,7,8,9]>>> >>> >>> >>> {k:v for k,v in zip(l1,l2)}{1: 4, 2: 5, 3: 6, 4: 7, 5: 8, 6: 9}>>> >>> >>> >>> x = {1: 4, 2: 5 阅读全文
摘要:
# 正则将匹配到的两个字段,都替换成某个值import re s0 = 'BOY and GIRL' s1 = re.sub(r'BOY|GIRL', 'HUMAN', s0) print s1 # HUMAN and HUMAN 阅读全文
摘要:
# In viewsdef zbsservice(request): #返回一个列表 v1 = models.Business.objects.all() # .value返回一个字典 v2 = models.Business.objects.all().values("id","caption","code") # .values_list 返回一个... 阅读全文
摘要:
views里返回数据为例: renturn render(request,'xxx.html',{'obj':123,'k1':[1,2,3,4],'k2':{'name':'yooma','age':'88'}} 获取单个数据 {{ obj }} {{k1.3}} {{k2.name}} 获取多个数据 {% for i in k1 %} {{i}} {% endfor %} 获... 阅读全文
摘要:
AutoField(Field) - int自增列,必须填入参数 primary_key=True BigAutoField(AutoField) - bigint自增列,必须填入参数 primary_key=True 注:当model中如果没有自增列,则自动会创建一个列名为id的列 from django.db imp... 阅读全文