0

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.

1
  • 1
    Typo: filer should be filter. Commented Nov 4, 2013 at 21:23

1 Answer 1

5

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.

Sign up to request clarification or add additional context in comments.

1 Comment

That did the trick, thanks for the answer , its a shame that i sometimes miss basic things

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.