Marc, There is a couple of ways to do this on top of the Django ORM. You probably want to use a many-to-many relationship with an extra index field. https://docs.djangoproject.com/en/dev/topics/db/models/#extra-fields-on-many-to-many-relationships
class SingularWorkFlow(models.Model): name = models.CharField(default=None, null=True) def __unicode__(self): return self.name class CompositeWorkFlow(models.Model): name = models.CharField(default=None, null=True) workflows = models.ManyToManyField(SingularWorkFlow, through='WorkFlowOrderedList') def __unicode__(self): return self.name class WorkFlowOrderedList(models.Model): composite = models.ForeignKey(CompositeWorkFlow) singular = models.ForeignKey(SingularWorkFlow) index = models.IntegerField(default=None, null=True) class Meta: ordering = ['index',] Brian Schott bfsch...@gmail.com On Nov 29, 2011, at 10:44 AM, Marc Edwards wrote: > I need some help in resetting my thinking on creating my Django data > model. > > I have previously created an XML schema definition for my data model, > but am now trying to re-create this XML data model in a Django data > model. > > In my XML schema, I had defined "collections" of XML complex types > that essentially were lists that I could XQuery. I used the ID & > IDREF tags to cross-reference my elements between lists of elements. > As XML is a tree structure, my schema defined a top down tree > hierarchy. Now I want to redefine this in a Django data model. > > In my primary scenario, I had a list of "singular" workflows that > constituted a "parent" element "catalog" of workflows, i.e. a workflow > catalog. Multiple "singular" workflows can be combined into an ORDERED > collection of workflows called a "reference" or "composite" workflow. > There are many composite/reference workflow instances with varied > ordered combinations of singular workflows. > > In my XML hierarchy, I used the IDREF tags to reference the "singular" > workflows from within the "reference" workflow element instance. > > In my Django object model, I can define a class for a "singular" > workflow...easy enough, and I can query the Django database model to > select the "singular" workflows. > > But, what is the correct method of now creating the "composite" > workflow that will reference the singular workflows? > > My pseudo-code for the composite workflow class looks like this... > > class SingularWorkFlow(models.Model): > pass > > class CompositeWorkflow(models.Model): > OrderedListOfSingularWorkflows = > list(models.ForeignKey(SingularWorkFlow) > > I don't think this will work, but would kindly ask for some guidance. > > Regards, Marc > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-users@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.