with template register loginview has custom contrib auth attribute and django django-forms django-views django-authentication django-users

template - Agregar campo personalizado a la tabla auth_user en django



register and login django (1)

Tienes:

email = moels.CharField(max_length=75)

Parece que solo tienes modelos mal escritos:

email = models.CharField(max_length=75)

Deseo agregar mi campo TrustAdministration personalizado a la tabla Auth_User en django

Aquí está mi Model.py

from django.db import models from django.contrib.auth.models import User class Trust(models.Model): name = models.CharField(max_length=200) class TrustAdministration(models.Model): user = models.OneToOneField(User) full_name = models.CharField(max_length=200) email = moels.CharField(max_length=75)

form.py

from django.contrib.auth.models import User from django.contrib.auth.forms import UserCreationForm from models import Trust, TrustAdministration class TrustForm(form.ModelForm): class Meta(): model = Trust class TrustAdministration(forms.ModelForm): class Meta(): model = TrustAdministration class UserCreateForm(UserCreationForm): class Meta(): model = User

view.py

def trust_registration(request): if request.POST: trust_form = TrustForm(request.POST, instance=Trust()) trust_admin_form = TrustAdministrationForm(request.POST,instance=TrustAdministration()) user_form = UserCreateForm(request.POST) if trust_form.is_valid() and trust_admin_form.is_valid() and user_form.is_valid(): username = request.POST[''username''] password = request.POST[''password''] new_user = User.objects.create_user(username=username, password=password) new_user.save() new_trust = trust_form.save() new_trust_admin = trust_admin_form.save(commit = False) new_trust_admin.trust = new_trust new_trust_admin.user = new_user new_trust_admin.email = username new_trust_admin.save() else: return HttpResponseRedirect(''/registration/trust_registration'') return HttpResponseRedirect(''/registration/trust_details'') else: trust_form = TrustForm() trust_admin_form = TrustAdministrationForm() user_form = UserCreateForm() return render(request, ''trust/trust_registration.html'', {''trust_form'': trust_form, ''trust_admin_form'' : trust_admin_form, ''user_form'' : user_form})

Cuando envío el formulario, indica que se requiere contraseña , pero el formulario de creación de usuarios muestra el campo de texto para contraseña1 y contraseña2 en el formulario.

Y también dime si es correcto o incorrecto crear una entrada de usuario para el modelo TrustAdministration .