【发布时间】:2015-12-12 13:47:29
【问题描述】:
您好,我正在为我的网站使用 Django 框架。我有一个项目中的视图,它将数据保存到数据库(模型)中。但是当我运行我的程序时,出现如下错误
ValueError: invalid literal for int() with base 10: '2015-08-24 12:27:58'
我的意见.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)
谁能告诉我这里有什么问题?提前致谢。
【问题讨论】:
-
为
OrcAwaiverBin模型粘贴models.py的代码 -
更新了我的模型字段
-
@gentle 请发布完整的堆栈跟踪!此外,您确定
self.request.session['ACL_gid']是整数,因为您正试图通过id获取GroupProfile对象?
标签: python django django-models django-views