Hi,

So you want to tie Contract with Product(s) with rebate_pct? You then need
custom intermediary m2m table say "ContractProduct" <see
https://docs.djangoproject.com/en/1.3/topics/db/models/#intermediary-manytomany>
for more. So in the end your models would probably look a alike following:

class Contract():
    contract_id = models.lIntegerField(...)
    products = models.ManyToManyField(Product, through='ContractProduct')

class ContractProduct():
    contract = models.ForeignKey(Contract)
    product = models.ForeignKey(Product)
    rebate_pct = models.DecimalField(max_digits=4, decimal_places=2)

So now you can link Contract with multiple Products adding custom rebate_pct
value to each link.

And what comes to rebate value, I think you want to keep value with product
linkage for two reasons:
1) It's a single scalar value
2) It's probably something that should not be changed ever after saving.

hth,

-- 

Jani Tiainen

On Thu, Jul 21, 2011 at 8:25 PM, newtodjango <nixmli...@gmail.com> wrote:

> Sorry about formatting. Also the there is a mistake.
>
> "I'd like to define the Product model..." should be
> "I'd like to define the Contract model...
>
> Thanks.
>
> --
> 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.
>
>

-- 
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.

Reply via email to