当我尝试:
StudyRecord.object.filter(user__name__contains= id )
django投下以下错误:
/ error_study / my_infor /中的AttributeError type对象'StudyRecord'没有属性'object'
回溯切换到复制并粘贴视图
C:\Python27\lib\site-packages\django-1.7.3py2.7.egg\django\core\handlers\base.py in get_responseresponse = wrapped_callback(request, *callback_args, **callback_kwargs) ...
▶ Local vars
c:\mystudio\tag_study\views.py in my_inforurrent_book = StudyRecord.object.filter(user__name__contains= id ) ...
▶ Local vars
class StudyRecord(models.Model):
user = models.ForeignKey(User)
book = models.CharField(max_length=128)
starttime= models.DateTimeField()
endtime = models.DateTimeField()
def save(self, *args, **kwargs):
self.slug = slugify(self.number)
super(StudyRecord, self).save(*args, **kwargs)
def __unicode__(self): #For Python 2, use __str__ on Python 3
return self.book
这是观点
def my_infor(request):
if request.method == "GET":
if request.user.is_authenticated():
id = request.user.id
StudyRecord.object.filter(user__name__contains= id )
return HttpResponse(current_book)
else:
return HttpResponse("error2")
context = RequestContext(request)
return render_to_response('tag_study/my_infor.html', context)
答案 0 :(得分:1)
它应该是对象,而不是对象
答案 1 :(得分:0)