Searching across two models

67 views
Skip to first unread message

Andy Byers

unread,
Sep 9, 2015, 7:25:45 AM9/9/15
to django-watson discussion group
class Article(models.Model):

        title = models.CharField(max_length=300)
article_id = models.IntegerField()
date_submitted = models.DateTimeField(blank=True, null=True, help_text="article.date_submitted")
date_published = models.DateTimeField(blank=True, null=True, help_text="published_articles.date_published")
date_accepted = models.DateTimeField(blank=True, null=True, help_text="calculated field, based on editor decisions")
date_rejected = models.DateTimeField(blank=True, null=True, help_text="calculated field, based on editor decisions")

class Author(models.Model):
"authors attached to an article"
article = models.ForeignKey(Article)
primary_contact = models.BooleanField(default=False)
seq = models.PositiveSmallIntegerField()
first_name = models.CharField(max_length=150)
middle_name = models.CharField(max_length=150, null=True, blank=True)
last_name = models.CharField(max_length=150)
country_code = models.CharField(max_length=255, null=True, blank=True)
email = models.CharField(max_length=320, null=True, blank=True)
url = models.CharField(max_length=320, null=True, blank=True)
affiliation = models.TextField(null=True, blank=True)

Is there a way to get a search on article to also look at the author table?

Carlton Gibson

unread,
Sep 9, 2015, 7:35:03 AM9/9/15
to django-watson discussion group
Hi Andy, 


It'll be something like: 

    watson.search("Search terms", models=(Article,Author,))
Reply all
Reply to author
Forward
0 new messages