웹 응용 프로그램에서 모든 영화를 다운로드 할 때마다 업 로더에게 영화가 다운로드되었음을 우편으로 알려야합니다. 나는 아래의 코드를 썼다. 나는 질의를 제대로하기가 어렵다고 생각한다.장고에서 객체를 검색 할 때 AttributeError가 발생했습니다.
AttributeError at /download/
'unicode' object has no attribute 'email'
모델 :
class Emovie(models.Model):
User=models.ForeignKey(User)
movie_file=models.FileField(upload_to='miiv')
movie_name=models.CharField(max_length=50)
email=models.EmailField() #email of the uploader
#other fields follows
Views.py
@login_required
def document_view(request, emovie_id, urlhash):
document=Emovie.objects.get(id=emovie_id, urlhash=urlhash)
downstats=Emovie.objects.filter(id=emovie_id, urlhash=urlhash).update(download_count=F('download_count')+1)
#where email notification starts
notify=Emovie.objects.filter(id=emovie_id.email)
send_mail('Your file has just been downloaded','this works','[email protected]',[notify])
response = HttpResponse()
response["Content-Disposition"]= "attachment; filename={0}".format(document.pretty_name)
response['X-Accel-Redirect'] = "/protected_files/{0}".format(document.up_stuff)
return response
어떻게 이것에 대해 갈 수 있나요?
'.. 그리고 [notify.email]'대신에 '[알릴] 교체'다음 라인 . – mariodev
@mariodev : 예, 그렇습니다. 고맙습니다. –
이 오류가 발생합니다. 'QuerySet'객체에는 'email'속성이 없습니다. 어떤 생각? – picomon