2
我試圖返回與當前相關的登錄用戶播放列表中,我得到一個錯誤說: AttributeError異常:「查詢集」對象有沒有屬性「has_header如何修復django中的AttributeError?
我已經包含了什麼,我相信是下面的代碼的相關部分。有關如何解決這個問題的任何建議?
views.py
playlist = UserPlaylist.objects.filter(profile=request.user)
return playlist
models.py
class UserProfile(models.Model):
user = models.OneToOneField(User)
def __unicode__(self):
return self.user
def create_user_profile(sender, instance, created, **kwargs):
if created:
UserProfile.objects.create(user=instance)
post_save.connect(create_user_profile, sender=User)
class Playlist(models.Model):
playlist = models.CharField('Playlist', max_length = 2000, null=True, blank=True)
def __unicode__(self):
return self.playlist
class Video(models.Model):
video_url = models.URLField('Link to video', max_length = 200, null=True, blank=True)
def __unicode__(self):
return self.video_url
class UserPlaylist(models.Model):
profile = models.ForeignKey(User)
playlist = models.ForeignKey(Playlist)
def __unicode__(self):
return unicode(self.playlist)
class Videoplaylist(models.Model):
video = models.ForeignKey(Video)
playlist = models.ForeignKey(UserPlaylist)
def __unicode__(self):
return unicode(self.playlist)
你可以發佈錯誤的完整追溯? –
發佈全景功能。目前它的立場是錯誤的。它不會返回一個HttpResponse。 – rantanplan