I'm making some sort of galactic map with the following classes defined in models.py:
class Star(models.Model): name = models.CharField(max_length=200) xcoord = models.FloatField() ycoord = models.FloatField() zcoord = models.FloatField() def __unicode__(self): return self.name + ' (' + str(self.xcoord) + ', ' + str (self.ycoord) + ', ' + str(self.zcoord) + ')' class Satellite(models.Model): name = models.CharField(max_length=200) description = models.TextField(blank=True, null=True) system = models.ForeignKey(System, related_name='satellites') def __unicode__(self): return self.name class Planet(Satellite): orbital = models.IntegerField() class Moon(Satellite): suborbital = models.IntegerField() orbits = models.ForeignKey(Planet, related_name='moons') What should I do so I can refer to an s.planets object containing all objects of class Planet with system==s? it seems like Star should have added def _get_planets(self): return self.planets def _set_planets(self, planet): self.planets.append(planet) planets = property(_get_planets, _set_planets) and Planet should have something like def __init__(self, *args, **kwargs): super(Planet, self).__init__(*args, **kwargs) self.star.planets.append(self) def save(self): super(Planet, self).save() Does this look accurate? --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---