Django - extra fields for user form -


I am developing in that site, I have a form of registering users such as userCreationForm . The said form only states that the fields are not in the default, but they are in the model such as email, first_name and last_name

  class RegisterForm (UserCreationForm):. Email = forms.EmailField (label = "email", required = true) first_name = forms Class field metro: model = user field = ("user name", "first_name", "last_name") (field name = "first name", required = true) last_name = forms.CharField (label = "last name", required = true) "," Email "," password1 "," password2 ") def __init __ (own, * args, ** kwargs): super (RegisterForm, self) .__ init __ (* args, ** kwargs) ['username' ',' Password1 ',' password2 '] for FIELDNAME: self.fields [FIELDNAME] .help_text = none   

My question is if there is a way to do that Other fields like an image field, birth date, etc. Add, so that I can create a more complete user profile? Or do I have to create my own user model? To add more fields, Django idiomatic approach is to create a second model where the user

is a ForeignKey . Then: django.db import model from django.contrib.auth.models import user class MyUser (models.Model): user = models.ForeignKey (user) # ... other fields . I.e. date of birthland (DOB), etc. #Example: Dob = Model.Defhed ()

Comments

Popular posts from this blog

ios - Adding an SKSpriteNode to SKScene from a child SKSpriteNode -

Matlab transpose a table vector -

c# - Textbox not clickable but editable -