First, my code to review:
class Edge(models.Model):
'''A link between two pages'''
u = models.ForeignKey(Page)
v = models.ForeignKey(Page)
class Page(models.Model):
en_title = models.CharField(max_length=200)
es_title = models.CharField(max_length=200)
en_text = models.CharField(max_length=1000)
es_text = models.CharField(max_length=1000)
# Alternative to using the Edge class:
# next = models.ForeignKey(Page)
# prev = models.ForeignKey(Page)
Here is an example of how pages might be arranged:
# Using class Edge:
# {2:4, 4:12, 12:82, 12:9, 9:7, 7:8, 8:None, 82:93, 93:None}
2-->4-->12-->9-->7-->8
\ \
`-->82-->93->None
# Only using Page class with next/pref attributes (delete Edge class):
# {pages}
None<--2<-->4<-->7<-->9<-->10<-->1<-->90-->None
The Edge class allows for more flexible structure of pathways for consumers to traverse. But a doubly linked list might be easier to use.
In short my 2 questions are:
- What would I need to code so a user could easily define structure and pages independently? I'll be using topological sort for content consumers.
- What other options do I have for implementing bilingual models?