这是我在这个网站上的第一个问题,如果有错误的方式,请原谅。如果有更具体的展示,请联系我,谢谢。我只是运行我的Django程序,那里是不对的。我已经搜索了很长时间了,但我无法修复它。当我转到详细页面时,会发生错误。
models.py
class UserProfile(models.Model):
belong_to = models.OneToOneField(to=User, related_name='profile',on_delete = models.CASCADE)
profile_image = models.FileField(upload_to='profile_image')
view.py
def detail(request, id):
context = {}
vid_info = Video.objects.get(id=id)
voter_id = request.user.profile.id
like_counts = Ticket.objects.filter(choice='like', video_id=id).count()
try:
user_ticket_for_this_video = Ticket.objects.get(voter_id=voter_id, video_id=id)
context['user_ticket'] = user_ticket_for_this_video
except:
pass
context['vid_info'] = vid_info
context['like_counts'] = like_counts
return render(request, 'detail.html', context)