l5x skrev: > Hello, > > I have code for searching: > > news = News.objects.filter( > Q(title__icontains=phrase) > | Q(tags__icontains=phrase) > | Q(short__icontains=phrase) > | Q(content__icontains=phrase) > | Q(author__icontains=phrase) > | Q(source__icontains=phrase) > )
> News model looks like that: > > class News(models.Model): > title = models.CharField(maxlength="100") > tags = models.CharField(maxlength="75") > short = models.TextField() > content = models.TextField() > author = models.ForeignKey(User, editable=False) > source = models.CharField(maxlength="100") > date = models.DateTimeField(auto_now_add=True) > status = models.IntegerField(editable=False, default="0") > def __str__(self): > return '%s' % (self.title) > class Admin(): > pass > You need to specify which fields in the User/Author table to match on (the default is the primary key , which doesn't make sense here). Something like |Q(author__username__icontains=phrase) Nis --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com 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 -~----------~----~----~----~------~----~------~--~---