您好我在我的网站上使用Django框架。我在项目中有一个View,它将数据保存到数据库中(Models)。但是当我运行我的程序时出现如下错误
ValueError: invalid literal for int() with base 10: '2015-08-24 12:27:58'
我的views.py
class ProcessCheckBinningView(JSONResponseMixin, View):
#model = OrcAwaiverBin
def post(self, request, *args, **kwargs):
status = 'error'
msg = "this is from me"
post_body = json.loads(self.request.body)
fab_value = post_body['fab']
technode_value = post_body['technode']
layer_value = post_body['layer']
print fab_value, technode_value, layer_value
print "submitted from the template f"
bin_object = OrcAwaiverBin()
# Record the last accessed date
bin_object.fab = fab_value
bin_object.technology = technode_value
bin_object.layer = layer_value
print "OKKKKK"
bin_object.created_by = '2015-08-24 12:27:58'
bin_object.date_modified = '2015-08-24 12:27:58'
bin_object.save()
return self.render_json_response(dict(status=status, msg=msg))
class CheckBinningView(TemplateView):
template_name = "orc_enable.html"
def get_context_data(self, *args, **kwargs):
context = super(CheckBinningView, self).get_context_data(*args, **kwargs)
fab = GroupProfile.objects.get(id=self.request.session['ACL_gid']).fab
gp = GroupProfile.objects.get(id=self.request.session['ACL_gid'])
context['fab'] = gp.fab
context['ngapp'] = "CMOD"
return context
我的模型字段:
date_created = models.DateTimeField(auto_now_add=True)
date_modified = models.DateTimeField(blank=True)
有人能告诉我这里的问题是什么吗?提前谢谢。
答案 0 :(得分:0)
根据错误提示,您应该已将bin_object.created_by
字段或bin_object.date_modified
字段声明为IntegerField
。
答案 1 :(得分:0)
问题是,Aswin说我的模型只接受整数值。我试图插入日期时间值。谢谢大家!