Re: Create a new user profile

2009-08-04 Thread Steven Nien
Hi, Thank cooteteom and Spajderix! Both of Your code works! Thank you very much! On Aug 4, 6:01 pm, cootetom wrote: > Hi, > > When you create the profile assign request.user to the user, so: > > profile_obj = UserProfile(user = request.user) > > Also in the UserProfile model make sure that the

Re: Create a new user profile

2009-08-04 Thread Spajderix
Hi, you have to create new "User" object, assign values to it and then assign this object to profile_obj. Example: from django.contrib.auth.models import User new_user = User() profile_obj = UserProfile() new_user.username = 'someusername' new_user.password = 'somepassword' new_user.save() pro

Re: Create a new user profile

2009-08-04 Thread cootetom
Hi, When you create the profile assign request.user to the user, so: profile_obj = UserProfile(user = request.user) Also in the UserProfile model make sure that the entries that are allowed to be blank are set up to allow that, eg: address = models.CharField(max_length=60, blank = True) birthd

Create a new user profile

2009-08-04 Thread Steven Nien
Hi all, I have built a model like this: class UserProfile(models.Model): address = models.CharField(max_length=60) birthday = models.DateField() user = models.ForeignKey(User) I render the model by the ModelForm: class UserProfileForm(ModelForm): class Meta: model = User