I am building a BlogApp and I was building a Feature BUT i am stuck on a Error.
when i open Detail page then i keep getting :-
'QuerySet' object has no attribute 'friends'
models.py
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE,default='',unique=True)
friends = models.ManyToManyField("Profile",blank=True)
def __str__(self):
return f'{self.user.username}'
CHOICES = (
('everyone','Every One'),
('friend','friend only'),
('none','Nobody'),
)
urls.py
path('<id>',views.detail_view,name='detail_view'),
Explanation of views.py
My code is supposed to , When i click on friends only
then it should check request.user
friends list AND if request.user
is exist then comment form will show. BUT this is keep showing me 'QuerySet' object has no attribute 'friends'
Error.
The Problem
When i put 'allow_comments == friend' in views
and select friend only in Browser
then i got this error.
Any help would be appreciated.
Thank You in Advance
question from:
https://stackoverflow.com/questions/65901498/queryset-object-has-no-attribute-friends 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…