django(2)
-
CSRF 적용된 Django 서버에 axios 이용하여 POST 요청하기
1. 2. axios.interceptors.request.use(request => { request.headers.delete['Content-Type'] = "application/x-www-form-urlencoded" request.headers.delete['X-CSRFToken'] = getCookie('csrftoken') return request }) data = {} var url = document.location.origin + '/' + APPNAME + '/site/' + this.site.uid axios.delete(url, data) .then(res => { console.log(res) })
2020.11.04 -
django query get last n records #Python #Django #queryset
django query get last n records last_ten = Messages.objects.filter(since=since).order_by('-id')[:10] # You can pass your queryset to reversed: last_ten_in_ascending_order = reversed(last_ten) # Or use [::-1] instead of reversed last_ten = Messages.objects.filter(since=since).order_by('-id')[:10][::-1]
2019.11.13