So I have just had a try with a new written UserManager and it works.

My model looks the following way now:

        from django.db import models
        from django.contrib.auth.models import User, UserManager
        import datetime

        class NewUserManager(models.Manager):
            def create_user(self, username, email, password, extradata):
                        """Creates and saves a User with the given username, 
e-mail and
password.
                        The extradata dictionary set as attributes to the 
model"""
                        now = datetime.datetime.now()
                        user = self.model(None, username, '', '', 
email.strip().lower(),
'placeholder', False, True, False, now, now)
                        user.set_password(password)
                        # username email and password do not have to be saved 
again
                        del extradata['username']
                        del extradata['email']
                        del extradata['password']
                        for key in extradata:
                                setattr(user, key, extradata[key])
                        user.save()
                        return user

        class CustomUserData(User):
                        # New Extra Data being saved with every User
                        city = models.CharField(max_length = 255)
                        [...]
                        # Use UserManager to get the create_user method, etc.
                        objects = NewUserManager()


and the save() changed to

        def save(self):
                CustomUserData.objects.create_user(
username=self.cleaned_data['username'],
                                                                                
        email=self.cleaned_data['email'],
                                                                                
        password=self.cleaned_data['password'],
                                                                                
        extradata=self.cleaned_data)


So this looks pretty nice to me. Anyone having another suggestion?
--~--~---------~--~----~------------~-------~--~----~
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