获得属性
var username = $(this).attr('username')
获取crsf认证
token = $('[name=csrfmiddlewaretoken]').val()
data:{'is_up':1,csrfmiddlewaretoken: token},
事件数据插入失败回滚
from django.db import transaction
try:
with transaction.atomic():
except:
# 局部禁用csrf认证
from django.views.decorators.csrf import csrf_exempt, csrf_protect
处理时间
from django.db.models.functions import TruncMonth
time_list = user.blog.article_set.annotate(month=TruncMonth('create_time')).values('month').annotate(
c=Count('title'))
# bs4爬虫处理解析html代码
from bs4 import BeautifulSoup
soup = BeautifulSoup(content, 'html.parser')
desc = soup.text.strip()[0:100]