On Oct 21, 4:01 pm, Lucasm <lordlucr...@gmail.com> wrote: > It seems that the following does not work as expected: > > from django.db import models > > class MyManager(models.Manager): > def create(self, *args, **kwargs): > print "I am called!" > return super(MyManager, self).create(*args, **kwargs) > > class OtherModel(models.Model): > pass > > class MyModel(models.Model): > other_model = models.ForeignKey(OtherModel, > related_name='my_models') > objects = MyManager() > > >>> other_model = OtherModel.objects.create() > >>> other_model.my_models.create() > > The message is not printed! > > (I'm using Django v1.2.3)
Expected behaviour - you need to set the `use_for_related_fields` flag. Read this: http://docs.djangoproject.com/en/1.2/topics/db/managers/#using-managers-for-related-object-access -- DR. -- 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.