Of course it'll give you error, suppose your User is class User(models.Model): first_name = models.CharField(maxlength=256)
class App(models.Model): user = models.ForeignKey(User, unique=True, editable=False) then use: try: user_exists = Application.objects.get(user__first_name='john') except Application.DoesNotExist: #whatever you want here Cheers, Deepak On Jun 15, 12:20 am, Vincent Nijs <[EMAIL PROTECTED]> wrote: > Hi, > > I have the following model > > class App(models.Model): > user = models.ForeignKey(User, unique=True, editable=False) > > In a view I now want to check if a user is indeed in the database table. I > tried the following > > user_exists = Application.objects.get(user='john') > > But this give the following error: > > invalid input syntax for integer: "john" > > Any ideas on how to do this check? > > Thanks, > > Vi ncent --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] To unsubscribe from this group, send email to [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---

