Re: Overriding contrib.auth User save()

2008-11-28 Thread sergioh
I did not notice you were trying to override in a wrong way, sorry about that. Actually for override the user model you need to: class CustomUser(User): #your new fields, DRY user fields objects = MyCustomManager() class MyCustomManager(models.Manager): def

Re: Overriding contrib.auth User save()

2008-11-28 Thread sergioh
On Nov 28, 8:02 am, bruno desthuilliers <[EMAIL PROTECTED]> wrote: > On 28 nov, 09:45, Paddy Joy <[EMAIL PROTECTED]> wrote: > > > Thanks however I'm guessing: > > > > admin.site.unregister(User) > > > admin.site.register(User, NewModelForm) > > > will only work in the admin site? > > Yes.

Re: Overriding contrib.auth User save()

2008-11-28 Thread bruno desthuilliers
On 28 nov, 09:45, Paddy Joy <[EMAIL PROTECTED]> wrote: > Thanks however I'm guessing: > > > > > admin.site.unregister(User) > > admin.site.register(User, NewModelForm) > > will only work in the admin site? Yes. > Not actually using the admin site at > the moment but would nice to have something

Re: Overriding contrib.auth User save()

2008-11-28 Thread Paddy Joy
Thanks however I'm guessing: > > admin.site.unregister(User) > admin.site.register(User, NewModelForm) > will only work in the admin site? Not actually using the admin site at the moment but would nice to have something that would work globally. I nearly have the monkey patch working however

Re: Overriding contrib.auth User save()

2008-11-27 Thread sergioh
Maybe you could override the save method in a New User Model Form: save_model(self, request, obj, form, change) So you can: admin.site.unregister(User) admin.site.register(User, NewModelForm) http://docs.djangoproject.com/en/dev/ref/contrib/admin/ I hope this could help you! And finally the

Re: Overriding contrib.auth User save()

2008-11-27 Thread bruno desthuilliers
On 27 nov, 17:11, Paddy Joy <[EMAIL PROTECTED]> wrote: > Thanks for the tips, signals would work except I need access to the > raw password when users are created. > > On further inspection it seems I would need to override the > UserManager, On even further inspection, you may in fact want to

Re: Overriding contrib.auth User save()

2008-11-27 Thread Paddy Joy
Thanks for the tips, signals would work except I need access to the raw password when users are created. On further inspection it seems I would need to override the UserManager, I know I can extend it with more methods but I don't think I can override it. Paddy On Nov 27, 12:39 am, sergioh

Re: Overriding contrib.auth User save()

2008-11-26 Thread sergioh
Signals are the better way to achieve. You usually override the save method when you need to define something related with the model itself, but in many cases signals are the better way to notify some function to do something if a model change (after save) def your_function(sender, instance,

Re: Overriding contrib.auth User save()

2008-11-26 Thread Alex Koshelev
Of course you can monkey-patch the User model but the better way is to use signals pre_ or post_save On Wed, Nov 26, 2008 at 13:54, Paddy Joy <[EMAIL PROTECTED]> wrote: > > I would like to override the save() method on the contrib.auth User > model so that I can run a routine when a user is

Overriding contrib.auth User save()

2008-11-26 Thread Paddy Joy
I would like to override the save() method on the contrib.auth User model so that I can run a routine when a user is created/modified. Is this possible or do I need to use a signal? I have tried overriding the User model like this but it never seems to call my code: from