I am working on a django project in which I create a set of three abstract models that I will use for various applications later. The problem I am facing is that I want to connect these models via ForeignKey, but django tells me that it cannot assign additional keys to the abstract model.
My current solution is to assign extra keys when I run the class in other applications. However, I am writing a Manager for abstract classes (books and pages) right now and must access these additional keys. What I'm basically trying to do is get the number of words that the book has statelessness, so without saving them in the page or book box.
The model looks something like this:
class Book(models.Models): name = models.CharField(...) author = models.CharField(...) ... class Meta: abstract = True class Page(models.Models): book = models.ForeignKey(Book) chapter = models.CharField(...) ... class Meta: abstract = True class Word(models.Models): page = models.ForeignKey(Page) line = models.IntegerField(...) ... class Meta: abstract = True
Please note that this model is just here to give an example of what I'm trying to do, so is this model (Book-Page-Word) not necessary from the point of view of implementation.
phoxley
source share