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 create_mycustom_user(.................):
           self.create(.......#user fields and your new custom
fields#........)
           self.set_password('222')
           self.save()

On Nov 28, 9:39 am, sergioh <[EMAIL PROTECTED]> wrote:
> 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.
>
> Actually as is a Form you are able to use it not just in the admin
> section, you could override the fields or add as many fields as you
> want, but you will need to define the validation methods for those new
> fields and also the save method, you could use it in any view and pass
> it to a template for rendering.
>
> An actually monkey patch may cause you problems for future versions,
> and if you are planing to have many applications sharing your django,
> it will cause you problems. I think it you could find a better
> solution, just keep going.
>
> Kind Regards,
>
> Sergio Hinojosa
>
>
>
> > > 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 I'm getting the
> > > following error, any idea?
>
> > > >>> from django.contrib.auth.models import UserManager
> > > >>> a=UserManager()
> > > >>> a.create_user(username='sdf', email='[EMAIL PROTECTED]', 
> > > >>> password='222')
>
> > > Traceback (most recent call last):
> > >   File "<console>", line 1, in <module>
> > >   File "/var/django/mysite/../mysite/hosting/models.py", line 166, in
> > > my_create_user
> > >     return _create_user(self, username, email, password)
> > >   File "/usr/lib/python2.5/site-packages/django/contrib/auth/
> > > models.py", line 100, in create_user
> > >     user = self.model(None, username, '', '', email.strip().lower(),
> > > 'placeholder', False, True, False, now, now)
> > > TypeError: 'NoneType' object is not callable
>
> > Your UserManager instance is not connected to any model, so it's model
> > attribute is None. Manager classes are meant to be used thru model
> > classes, not directly.
>
> > IOW, you want:
>
> > from django.contrib.auth.models import User
> > user = User.objects.create_user(username='sdf', email='[EMAIL PROTECTED]',
> > password='222')
>
> > HTH
--~--~---------~--~----~------------~-------~--~----~
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