handlers.py
class ChatHandler(BaseHandler):
model = ChatMsg
allowed_methods = ('POST', 'GET')
def create(self, request, text):
message = ChatMsg(user = request.user, text = request.POST.get('text', '')),
message.save()
def read(self, request):
base = ChatMsg.objects
response = base.all()
return response
template
...
$(function(){
$('.chat-btn').click(function(){
var token = getCookie('csrftoken')
$.ajax({
url: '/api/post/',
type: 'POST',
dataType: 'application/json',
data: {text: $('.chat').val()}
})
})
})
...
Получаю ошибку 405 method is not allowed. Как быть?