Manager instance is accessed by model class not instance. So there is
no way to get model instance inside manager method (of course except
situations when you pass it directly). If you need some extra
functionality for instances the best way is to create model methods.
Manager operates with the set of model instances (rows) or have some
common purposes.

On Feb 24, 7:19 pm, davenaff <[EMAIL PROTECTED]> wrote:
> What are the best practices for using Managers?
>
> From the Django model reference, I find this quote
>
> "Adding extra Manager methods is the preferred way to add "table-
> level" functionality to your models. (For "row-level" functionality --
> i.e., functions that act on a single instance of a model object -- use
> Model methods, not custom Manager methods.)"
>
> However, when looking at the auth models, I see these two methods
> defined:
>
> def create_user(self, username, email, password=None):
> def make_random_password(self, length=10,
> allowed_chars='abcdefghjkmnpqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ23456789'):
>
> These two methods seem to involve situations where they need to act on
> a model, but the object instance hasn't been created yet.  Should
> managers always be used for this?
>
> Have people placed similar functionality within the model classes
> directly?  I suppose it depends on whether you need the functionality
> in absence of an object instance...
>
> Thanks!
> Dave
--~--~---------~--~----~------------~-------~--~----~
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
-~----------~----~----~----~------~----~------~--~---

Reply via email to