Reputation: 1281
here is my model :
class company_profile(models.Model):
user=models.ForeignKey(User, unique=True)
company=models.CharField(max_length=200)
def __unicode__(self):
return self.company
and when i got django shell i did the following, it worked correctly :
from my_app.models import company_profile
everything = company_profile.objects.all()
# this gives me the correct out put of the existing company names ,
but when i do the following :
username = company_profile.objects.all().filer(user='rakesh')
this is the error , that i am getting :
ValueError: invalid literal for int() with base 10: 'rakesh'
how can i solve this , or is my query wrong.
Upvotes: 0
Views: 63
Reputation: 37364
Your query is wrong. The user="rakesh"
clause needs to get either a User
instance or the PK of a User
instance.
You may mean filter(user__username='rakesh')
or something, depending on what fields you have on User
.
Upvotes: 5