I want to create the relationship between a person and the news article it got mentioned in.
person/models.py
class Person(models.Model):
first_name = models.CharField(max_length=20)
last_name = models.CharField(max_length=40)
news_mentioned = models.ManyToManyField(News, blank=True)
news/models.py
class News(models.Model):
title = models.CharField(max_length=250)
abstract = models.TextField(max_length=1000, null=True, blank=True)
description = models.TextField(max_length=5000, null=True, blank=True)
url = models.URLField(unique=True)
ne_person = models.CharField(max_length=250, blank=True, null=True)
Extract from the celery task:
article = News.objects.get(pk=pk)
person = Person.objects.update_or_create(first_name=fname, last_name=lname)
person.save()
mentioned = Person.objects.get(person.id).news_mentioned(article.id)
What am I making wrong here