D
D
dustik2014-04-22 14:30:01
Django
dustik, 2014-04-22 14:30:01

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)

Tried various examples (for example, given here = softwaremaniacs.org/forum/django/52120 ), but nothing worked for me.
I ask the respected community to help.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
dustik, 2014-04-23
@dustik

The issue has been resolved according to the recommendations given in this article: stackoverflow.com/questions/1913913/django-inlinef...

I
Igorzp, 2014-04-22
@Igorzp

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

E
EvilX, 2014-04-22
@EvilX

To do this, you need to use formset.
https://docs.djangoproject.com/en/dev/topics/forms...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question