I have an intermediate model which is as follows -
class Link_Book_Course(models.Model):
book = models.ForeignKey(Book)
course = models.ForeignKey(Course)
image = models.CharField(max_length = 200, null=True)
rating = models.CharField(max_length = 200,null=True)
def __unicode__(self):
return self.title
def save(self):
self.date_created = datetime.now()
super(Link_Book_Course,self).save()
I've created a new Book and a new Link_Book_Course, and am trying to add that book to the Link_Book_Course
call the Link_Book_Course newCourseLink
and call the Book newBook
.
I thought that this call would work -
newCourseLink.book_set.add(newBook)
but Django throws an error saying that newCourseLink has no attribute book_set- does anyone know why?
Furthermore, how can I add the Book to newCourseLink
?
Thanks