Hi,

I've been using Djangos manytomany functionality to add values into the auto
generated table, here are my model classes:

class Contract_Item(models.Model):
    quant = models.DecimalField(max_digits=10, decimal_places=4)
    item = models.OneToOneField(Item)

class Contract(models.Model):
    contract_no = models.AutoField(primary_key=True)
    start_date = models.DateField()
    end_date = models.DateField()
    change_date = models.DateField()
    contract_type = models.ForeignKey(Contract_Type)
    comment = models.CharField(max_length=300)
    creno = models.ManyToManyField(Creditor)
    debno = models.ManyToManyField(Debtor)
    contract_items = models.ManyToManyField(Contract_Item)

when i try to read values into the manytomany table with the following code:
(new_contract is the contract object i used to read values into)
new_contract = models.Contract(modelattribute=variable)
for items in i_contract_item_list:
            new_contract.contract_items.add(items)
new_contract.save()

However when i run this the following error occurs and I cant seem to find
the problem:

AttributeError: 'Contract' object has no attribute 'contract_items'

Any help would be appreciated!

Thanks,

JP De Villiers

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@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