Using the following model it is possible to add an arbitrary number of
components (with a quantity) to configurations.

class Configuration(meta.Model):
    pass #### fields definition.
    class META:
        pass #### meta definition

class Component(meta.Model):
    code = meta.CharField('Code', maxlength=64, unique=True)
    full_desc = meta.TextField('Description', blank=True)
    price = meta.FloatField('Price', max_digits=6, decimal_places=2)

    class META:
        admin = meta.Admin()

    def __repr__(self):
        return self.code

class Intermediary(meta.Model):
    component = meta.ForeignKey(Component, blank=True, core=True)
    quantity = meta.PositiveIntegerField('Quantity', blank=True)
    estimate = meta.ForeignKey(Configuration, edit_inline=True)

I'd like that once a user select or change a component from the
component's listbox, its price appears somewhere. I'd like to avoid the
javascript solution, as probably it wouldn't be trivial and I don't
know javascript well.. So I thought to change __repr__ to return a
tuple containing self.code and self.price, but some problems arise.

Can you suggest some alternatives?

Thanks,
paolo

Reply via email to