I've got two models, something like this:

class Category(models.Model):
    name = models.CharField(max_length=60)

class Product(models.Model):
    sku = models.CharField(max_length=20)
    categories = models.ManyToManyField(Category)

I want to overload the save method to automatically add certain
products to certain categories in special cases:

def save(self, *args):
   models.Model(save, *args)
   category = Category.objects.all()[0]
   self.categories.add(category)

This does not work, I'm sure it's saving ManyToMany relationships
later on in the save process.  Is there a way to make this work?

-- 
Adam Olsen
SendOutCards.com
http://www.vimtips.org
http://last.fm/user/synic

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

Reply via email to