当前页面刷新(console):
location.reload()
给动态添加的控件添加js事件(委托):
<ul> <li>菜单一</li> <li>菜单二</li> </ul> //直接添加 $('li').click(function () { }) //通过委托,动态添加的控件,响应js事件 $('ul').on('click', 'li', function () { })
添加一个a标签,什么都不做:
pager_list.append('<a href="javascript:void(0);''>上一个</a>)
XSS, 安全的渲染:
前端:
<div class="pagination">
{{ str_pager|safe }}
</div>
后端:
mark_safe()
给标签添加自定义属性,获取属性值:
filter查询使用字典替换键值对:
models.tb.objects.filter(id=123)
dic = {'id': 123, 'age__gt': 3}
models.tb.objects.filter(**dic)
修改主键关联(默认是id):
class Province(models.Model):
name = models.CharField(max_length=32,)
# nid = models.Intergar(unique=True) # 唯一
class City(models.Model):
name = models.CharField(max_length=32)
pro = models.ForeignKey("Province", to_filed='id')
正向查找: 具有外键字段
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
function bindtdEditEvent() { $('tbody').on('click', '.td-edit', function () { $('.modal, .shade').removeClass('hide') var tds = $(this).parent().prevAll() {#$('.modal input[name="caption"]').val(tds[0].innerText)#} {#$('.modal input[name="id"]').val(tds[1].innerText)#} tds.each(function () { {#$(this).parent().prevAll().each(function () {#} var text = $(this).text() var name = $(this).attr('param') {#console.log(text)#} console.log(name) {#$('.modal input[name="'+ name +'"]').val(text)#} $('.modal input[name="'+ name +'"]').val(text) }) }) }
post请求获取多个参数:
def index(request):
request.POST.get('k')
#checkbox, select(multi)
request.POST.getlist('k')
not in
models.Teacher.objects.exclude(id__in=[1,2,3])