Answer the question
In order to leave comments, you need to log in
I added my fields to the model User, I can’t display it in the user registration template, how to display it?
I added my fields to the model User, since the default fields are not enough for me,
how can I display the other three fields?
model.py:
class Profile(models.Model):
user = models.OneToOneField(User, related_name='profile', on_delete=models.CASCADE,
verbose_name='Пользователь')
avatar = models.ImageField(null=True, blank=True, upload_to='user_pics', verbose_name='Аватар')
second_name = models.CharField(max_length=100, null=True, blank=True, verbose_name='Отчество')
gender = models.CharField(max_length=20, verbose_name='Пол',
choices=GENDER_CHOICES, default=USER_GENDER_CHOICES)
country = models.CharField(max_length=20, verbose_name='Страна',
choices=COUNTRY_CHOICES, default=USER_COUNTRY_CHOICES)
def __str__(self):
return self.user.get_full_name() + "'s Profile"
class Meta:
verbose_name = 'Профиль'
verbose_name_plural = 'Профили'
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question