1
change photo
field in userProfile
like this:
class userProfile(models.Model):
name = models.CharField(max_length=30, default='')
user = models.OneToOneField(User)
photo = models.ImageField(blank=True,upload_to=url)
email = models.EmailField(max_length=75)
def __unicode__(self):
return self.user.username
This allow you to add userprofile without photo.
simply add userProfile
when create new user like this:
def register_view(request):
form = RegisterForm()
if request.method == "POST":
form = RegisterForm(request.POST)
if form.is_valid():
first_name = form.cleaned_data['first_name']
usuario = form.cleaned_data['username']
email = form.cleaned_data['email']
password_one = form.cleaned_data['password_one']
password_two = form.cleaned_data['password_two']
u = User.objects.create_user(first_name=first_name,username=usuario,email=email,password=password_one)
u.save()
#add user profile
user_profile = userProfile(name=first_name,user=u,email=email)
user_profile.save()
return render_to_response('home/thanks_register.html',context_instance=RequestContext(request))
else:
ctx = {'form':form}
return render_to_response('home/register.html',ctx,context_instance=RequestContext(request))
ctx = {'form':form}
return render_to_response('home/register.html',ctx,context_instance=RequestContext(request))
Source:stackexchange.com