> If you're setting all these things in the User object, then reverse the > logic slightly: > > new_user = User.objects.create(username=username, > email=email, > is_active=True, > first_name=firstname, > last_name=lastname) > new_user.set_password(password) > new_user.save() # needed because set_password() doesn't call > save() > > > new_user.save()
ok, this is almost same as my code, well, I supplied the password in create() method. I can use the set_password, though. > > # Create Extended profile > > up=UserProfile.objects.create(user=new_user) > > up.firstname = new_user.first_name > > up.lastname = new_user.last_name > > up.save() > > Again, this could become a one-liner (split over multiple lines for > presentation): > > UserProfile.objects.create(user=new_user, > firstname=firstname, > lastname=lastname) > > > I'm not sure what you're seeing the problems are with your current > approach. You need to supply a minimum amount of information to the User > and UserProfile object to create them, so that says that certain > parameters are required. You're supplying those. I've shaved a couple of > lines off, but it's only minor stuff. > > Given that minimal information requirement and the fact that you're > creating both objects in the same place -- a good thing so that nothing > is forgotten -- what else are you hoping to trim? > > Regards, > Malcolm I am not hoping for the trims, and lesser code, just examples and suggestions from other users app, who dealt with the same profile thing and implementated some cool way to do it. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected] 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 -~----------~----~----~----~------~----~------~--~---

