Hi Brant, thanks for your comment. Effectively the model was wrong and
your fix has been very useful.

This is the working version:

from django.core import meta
class Ingredient(meta.Model):
    fields = (
        meta.CharField('name', 'Name', maxlength=128),
        meta.TextField('description', 'Description', blank=True),
    )

    admin = meta.Admin()

    def __repr__(self):
        return self.name

class Recipe(meta.Model):
    fields = (
        meta.CharField('name', 'Name', maxlength= 128, unique=True),
        meta.TextField('description', 'Description')
    )

    admin = meta.Admin()

    def __repr__(self):
        return self.name

class Intermediary(meta.Model):
    fields = (
        meta.ForeignKey(Ingredient, blank=True, core=True),
        meta.PositiveIntegerField('quantity', 'Quantity', blank=True),
        meta.ForeignKey(Recipe, edit_inline=True)
    )

I also have changed the order of classes definition. In the previous
model it was Ingredient, Intermediary, Recipe: adding inside
Intermediary a reference to Recipes, it gave: NameError: name 'Recipe'
is not defined

So the model now defines classes in this order: Ingredient, Recipes,
Intermediary and all works fine.

My question is.. if order matters, is there the possibility, expecially
in complex models, to reach a "deadlock" condition?

Thanks,
paolo

Reply via email to