hey david,
ah - thanks so much! i made two mistakes: using abstract - and
linking to self rather than to Node. i'm guessing here - butu are two
models/tables created and linked together rather than a single 'uber'
table?
anyway, i'm back up and running on my fledgling project - thanks to
you!
Hi Paul,
So long as the common model is not abstract, it should work. Also, the
common model must be the one that contains the parent field, and it
should link to "Node" and not "self".
Using my first example, you should be able to traverse the tree using
Node.parent and Node.children. Trav
hi david,
many thanks for your help there. i initially tried the inheritance
method - buut found that my tree traversal broke when trying to
traverse a tree made of different types (ie, Node & Jobs). maybe i
did something wrong? ie, should i be able to make a tree from those
two types if derive
Hi Paul,
You've got a couple of options for this. The first uses inheritance:
class Node(models.Model):
parent = models.ForeignKey("Node", blank=True, null=True,
related_name="children")
class Job(Node):
pass
class Shot(Node):
pass
The second uses generic
hi,
I'm designing my first django app and would appreciate any advice how
best to organise my models.
I have a hierarchal model called Node. this allows me to create a
hierarchy of nodes - and perform hierarchal operatoins. So far so
good. each node can be of two 'types':
1/ job
2/ shot
I di
5 matches
Mail list logo