Re: Improvement: documentation example for extra Manager methods
On 13 nov, 14:53, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote: > Hi, > > I am building a custom Manager for adding extra methods that return > filtered querysets. > I believe this is a common case for custom Managers. Yes, indeed. > Digging into the documentation [1], the only example emphasises on the > ability to return anything from a Manager method. However, I miss a > standard example for methods that DO return a filtered queryset. > I am still struggling with my custom Manager method, which raises an > error in my project ('NoneType' object has no attribute '_meta'). Any > hint? Not without the relevant source code and the full traceback. Sorry, my crystall ball is out for repair. > My custom Manager method is like this: > def active(self): > return self.get_query_set().filter(status=STATUS_ACTIVE) or more simply: return self.filter(status=STATUS_ACTIVE) But this won't solve your problem anyway. --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Re: Improvement: documentation example for extra Manager methods
I found the origin on my error ('NoneType' object has no attribute '_meta'). I used a wrong (old?) syntax for adding custom Manager to my Model: ModelClass.objects = MyCustomManager() # After Model and Manager definitions My custom Manager should have been attached in the model definition (as found in the Manager documentation): objects = MyCustomManager() # And manager definition had to be moved before the Model definition Still, my initial message is valid: there is no standard example about custom Manager method that returns a filtered queryset :-) --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---
Improvement: documentation example for extra Manager methods
Hi, I am building a custom Manager for adding extra methods that return filtered querysets. I believe this is a common case for custom Managers. Digging into the documentation [1], the only example emphasises on the ability to return anything from a Manager method. However, I miss a standard example for methods that DO return a filtered queryset. I am still struggling with my custom Manager method, which raises an error in my project ('NoneType' object has no attribute '_meta'). Any hint? My custom Manager method is like this: def active(self): return self.get_query_set().filter(status=STATUS_ACTIVE) Based on your feedback, I could raise a ticket for updating the documentation. Thanks. [1] http://docs.djangoproject.com/en/dev/topics/db/managers/#adding-extra-manager-methods --~--~-~--~~~---~--~~ 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 [EMAIL PROTECTED] For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~--~~~~--~~--~--~---