I have two models Profile and Avatar.
models.py
class Profile(models.Model):
user = models.ForeignKey(User)
profile_name = models.CharField(blank=True, max_length=50)
def __unicode__(self):
return u'%s %s' % (self.user, self.profile_name)
class Avatar(models.Model):
user = models.ForeignKey(User)
paths = models.CharField(max_length=100)
def __unicode__(self):
return u'%s %s' % (self.user,self.paths)
I want to do a seach on the profile_name field (from Profile model) and get the paths to the pictures stored on the field paths (from the Avatar model).
view.py
profile_name_search = Profile.objects.filter(profile_name=usr_name)
user_avatar = Avatar.objects.filter(user=profile_name_search.user.id)
usr_name variable is passed from a form filed.
For some reason I'm getting this error:
'QuerySet' object has no attribute 'user'
user_avatar = Avatar.objects.filter(user=profile_name_search.user.id)
Any ides?