浏览代码

Don't raise error 500 on accessing /pins/upload-pin uri

Fixes #81
tags/v1.0.0
Krzysztof Klimonda 11 年前
父节点
当前提交
435c41e450
共有 1 个文件被更改,包括 7 次插入7 次删除
  1. +7
    -7
      pinry/pins/views.py

+ 7
- 7
pinry/pins/views.py 查看文件

@@ -1,10 +1,5 @@
import json

from django.contrib.auth import REDIRECT_FIELD_NAME
from django.contrib.auth.decorators import login_required
from django.contrib import messages
from django.http import HttpResponse
from django.utils.decorators import method_decorator
from django.core.urlresolvers import reverse
from django.http import HttpResponseRedirect
from django.views.generic import CreateView

from braces.views import LoginRequiredMixin, JSONResponseMixin
@@ -18,6 +13,11 @@ class CreateImage(JSONResponseMixin, LoginRequiredMixin, CreateView):
model = Image
form_class = ImageForm

def get(self, request, *args, **kwargs):
if not request.is_ajax():
return HttpResponseRedirect(reverse('pins:recent-pins'))
super(CreateImage, self).get(request, *args, **kwargs)

def form_valid(self, form):
image = form.save()
return self.render_json_response({


正在加载...
取消
保存