我收到以下错误消息,这不是很有帮助,并且仅此行没有其他错误...
**(<class 'django.contrib.auth.models.DoesNotExist'>)**
这是代码(它是一个ajax调用)
@login_required
@csrf_exempt
def smartpage_create_ajax(request):
if request.POST:
try:
json_dict = json.loads(request.POST['site'])
page = Content()
page.name = json_dict['name']
page.user(request.user)
page.json = request.POST['site']
page.save()
return HttpResponse('ok')
except Exception as e:
return HttpResponse('%s (%s)' % (e.message, type(e)))
有人可以告诉我这意味着什么,因为它以前有效。
谢谢你。
更新:
class Content(models.Model):
name = models.CharField(max_length=80, blank=True)
logo = models.ImageField(upload_to="/logos", blank=True)
json = models.TextField()
objects = ContentManager()
#FK
user = models.ForeignKey(User, related_name="contentpages", blank=True)
js
$.ajax(
{
type: "POST",
url: '../content/createpage',
data: "site="+encodeURIComponent(JSON.stringify(site)),
dataType: "json",
success: function(ret)
{
// console.dir(ret);
if(ret.result)
{
$('#build-btns').html(ret.html);
}
else
{
//report no builds left
$('#build-btns').after(ret.html);
}
},
error: function(xhr, textStatus, errorThrown)
{
console.log(xhr, textStatus, errorThrown + 'error');
return false;
},
complete: function()
{
}
});
},