Hi,
I think you must define your own user model, with inherit from django user
model...
class User(AbstractUser): bio = models.TextField(max_length=500, blank=True)
location = models.CharField(max_length=30, blank=True) birth_date = models.
DateField(null=True, blank=True)

and settings:
AUTH_USER_MODEL = 'core.User'

source:
https://simpleisbetterthancomplex.com/tutorial/2016/07/22/how-to-extend-django-user-model.html

po 11. 6. 2018 v 16:37 odesílatel Pravin Yadav <pk.ja...@gmail.com> napsal:

> 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
> <https://groups.google.com/d/msgid/django-users/05199455-aad3-4390-ac93-d902f2361680%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
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/CADS85tyidM_fBZPw9CjDxYp3i%3DjoAZRLko5GB5h3%2BN-K52D8Mw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to