I suggest you have a look at the "Trees and Graph" section of the
Django Packages website[0]. I've personally used MPTT and Treebeard
in the past without too much trouble.
You could also a field able to store composite data structures
such as JSONField or even a dedicated PostgreSQL type[1] to efficiently store
such data.
Cheers,
Simon
[0] https://djangopackages.org/grids/g/trees-and-graphs/
[1] https://www.postgresql.org/docs/current/sql-createtype.html
Le mardi 18 février 2020 18:13:39 UTC-5, test a écrit :
Let's say I have:Calculator #1:Expression: (True AND False) AND (True OR False)This expression should be a child of some calculator.class Calculator(models.Model):name = ...class Expression(models.Model):parent = models.ForeignKey(Calculator)boolean = AND or ORsub_exp1 = models.ForeignKey(Expression)sub_exp2 = models.ForeignKey(Expression)When I query all the expressions for the Calculator #1, I should get all the subexpressions.1 AND 2 52 AND 3 43 leaf node of True4 lead node of False5 OR 6 76 leaf node of True7 leaf node of FalseFrom this, I can quickly apply my parse tree.How would I display the base case/leaf nodes in my model? Also, is there a better way?Thanks, I would really appreciate any help
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/5ec92ddf-78b7-477a-aa0c-c7bc2a5ef005%40googlegroups.com.
No comments:
Post a Comment