Answer the question
In order to leave comments, you need to log in
Django - how to get one form for two models?
Hello.
I'm still wildly sorry, but I broke my whole head trying to figure out the problem.
The essence of the problem:
for the specified data model, I can’t get a form that would contain both the data of the User model and the data from the User2 model
#models.py
from django.db import models
from django.contrib.auth.models import User
class User2(models.Model):
# поле для связки со встроенной моделью пользователя Django
user = models.ForeignKey(User, unique=True)
# новое поле для отчества
sur_name_user = models.CharField(max_length=200, blank=True, null=True)
Answer the question
In order to leave comments, you need to log in
The issue has been resolved according to the recommendations given in this article: stackoverflow.com/questions/1913913/django-inlinef...
You don't need two forms. It is better to take the AbstractUser model and make the necessary fields in it than to make a model for one field.
Custom User
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question