Hello,

I want to add the one or more fields in User Models/Table.
Kindly let me know about this module.

My code below:-

def register(request):

if request.method == 'POST':
first_name = request.POST['first_name']
last_name = request.POST['last_name']
email = request.POST['email']
password = request.POST['password']
username= str(first_name).lower() + str(last_name).lower()
userdatalist = User.objects.filter(email=email).count() or 
User.objects.filter(username=username).count()
if userdatalist == 0:
new_user = User.objects.create_user(
username= email,
first_name=first_name,
last_name=last_name,
email=email,
password=password,
is_active=0,
age=age
)
hostname = request.get_host
context = {'first_name': first_name, 'last_name': last_name, 'pk': 
new_user.id, 'hostname': hostname}
to_email = email
from_email = 'VideoWithFriends'
html_message = render_to_string('mails/useractivation.html', context)
subject = 'Your account has been created successfully.'
email = EmailMultiAlternatives(subject, html_message, from_email, 
[to_email])
email.attach_alternative(html_message, "text/html")
if(email.send()):
success = 1
return HttpResponse(success);
else:
success = 2
return HttpResponse(success);
else:
error = 0
return HttpResponse(error);

I haven't created any model of User. I have called the predefined models of 
User.
When i'm adding extra fields like (age). it's showing errors.
kindly let me how  it will be fixed.


Thanks,
Pravin Yadav

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/05199455-aad3-4390-ac93-d902f2361680%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to