This may be more of a general database design question, but I want to
come up with something that works with Django's ORM.

I have four bits of information that I want to link together. Generic
packages, package versions, groups of packages and a profile that
brings them together.

The final goal is a Profile that binds the Packages from a Group to
specific Versions.

I have a solution at the moment but it seems a bit clumsy for what
seems like something that would be commonly encountered.

4 models: Package, Version, Group and Profile. I've omitted the id
primary key column on the examples.

Package:
| name   |
--
| django |
| python |

Version:
| package_id | version |
--
|          1 |     1.0 |
|          1 |     1.1 |
|          2 |     2.4 |
|          2 |     2.6 |

Group:
| name |
--
| django_stack |

group_packages:
| group_id | package_id |
--
|        1 |          1 |
|        1 |          2 |

Profile:
|        name | group_id |
--
| django_prod |        1 |
|  django_dev |        1 |

profile_packageversion:
| profile_id | version_id |
--
|          1 |          1 |
|          1 |          2 |
|          2 |          3 |
|          2 |          4 |

I can get what I need from a two step process, but is this the best or
most direct way to achieve this?

for package in profile.group.packages.all():
    print package.name
    for version in package.versions.all():
        print version

Is there a nicer way to do this? Is there a different model structure
that I could use?

Jonathan

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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.


Reply via email to