Hello all- I have tried a couple of tips found on the list to solve my problem with circular model imports, but with no lucks. Here is my basic schema:
#foo/models.py from bar.models import Formula class Variable(models.Model): amount = models.FloatField(null=True) is_formula = models.BooleanField(default=False) formula = models.OneToOneField(Formula, null=True, related_name="variable_formula") def get_amount(self): if self.is_formula: return self.formula.evaluate() else: return self.amount #bar/models.py from foo.models import Variable class Formula(models.Model): formula = models.TextField() # Where formula is a text string like 'var:1337*var:42', and the numbers are id numbers. def calculate(self): # re stuff for each_found_variable in groups(): # Simplified to show process - this obviously doesn't work. raw_string.append(Variable.objects.get(id=this_id).get_amount()) return eval(raw_string, stuff_to_make_eval_safe) In this case, the circular reference occurs only in a method of the class - I don't know if this makes a difference. How can I structure my import statements so that this is possible? I should note that there are more than one variable, so that combining everything into one models file is not really possible (and doesn't really address the chicken/egg problem either). I thought I saw a recent svn commit that addressed this problem, but can't find it now. Any help would be greatly appreciated? -- ############################ Chris Mutel Ökologisches Systemdesign - Ecological Systems Design Institut f.Umweltingenieurwissenschaften - Institute for Environmental Engineering ETH Zürich - HIF C 42 - Schafmattstr. 6 8093 Zürich Telefon: +41 44 633 71 45 - Fax: +41 44 633 10 61 ############################ --~--~---------~--~----~------------~-------~--~----~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---