Re: post_save signal to create the new user profile

2009-09-13 Thread Peter Bengtsson
Signals or no signals I think your profile model is wrong. By making it a subclass of User you're effectively getting all the fields of the User model. Write your profile model like this instead: class Employee(models.Model): user = models.ForeginKey(User) address = models.CharField(...)

Re: post_save signal to create the new user profile

2009-09-13 Thread Dmitry Gladkov
Found My mistake, create parent_link: class Employee(User): user = models.OneToOneField(User, parent_link=True) address = models.CharField(max_length=50, null=True, blank=True) phone1 = models.CharField(max_length=15, null=True, blank=True) phone2 =

post_save signal to create the new user profile

2009-09-13 Thread Dmitry Gladkov
Hi! I've got user profile, that uses multi-table inheritance: class Employee(User): address = models.CharField(max_length=50, null=True, blank=True) phone1 = models.CharField(max_length=15, null=True, blank=True) phone2 = models.CharField(max_length=15, null=True, blank=True)

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

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()

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)

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 =