Reputation: 141
here am looking for the particular data of logged in user to display in their profile i don't know how to do that. this is the error i get "'User' object is not iterable" please help me .
views.py
def users_homepage(request):
merchant=Merchant.objects.filter(request.user)
models.py class Merchant(models.Model):
user=models.OneToOneField(User,on_delete=models.CASCADE, primary_key=True)
shop_name=models.CharField(max_length=100)
phone_number=models.IntegerField(null=True)
dashboard.html
{%for merchan in merchant%}
<h1>{{merchan.shop_name}}</h1>
{%endfor%}
thanks in advance
Upvotes: 0
Views: 290
Reputation: 2547
You need to specify which field you're filtering on, change the View to:
def users_homepage(request):
merchant=Merchant.objects.filter(user=request.user)
Upvotes: 1