
Ronaldo Ricardo Mata Rodriguez
Preguntafrom django.db import models from django.contrib.auth.models import User class UserProfile(models.Model): user = models.OneToOneField(User, primary_key=True, verbose_name='user', related_name='profile') avatar_url = models.CharField(max_length=256, blank=True, null=True) def __str__(self): return self.first_name
from django.contrib import admin from .models import Post, Comment, UserProfile @admin.register(UserProfile) class UserProfileAdmin(admin.ModelAdmin): list_display = ('first_name', 'email')
error
<class 'post.admin.UserProfileAdmin'>: (admin.E108) The value of 'list_display[0]' refers to 'first_name', which is not a callable, an attribute of 'UserProfileAdmin', or an attribute or method on 'post.UserProfile'. <class 'post.admin.UserProfileAdmin'>: (admin.E108) The value of 'list_display[1]' refers to 'email', which is not a callable, an attribute of 'UserProfileAdmin', or an attribute or method on 'post.UserProfile'.
¿Por qué? si el modelo User tiene un atributo llamado first_name y email ¿Que sucede aqui?

Diego Forero
Hola para poder los dos datos puedes en el método
__str__
def __str__(self): return '{} - {}'.format(self.user.first_name, self.user.email`
Aunque no es la mejor practica.
Otra cosa que puedes hacer es usar un modelo custom para el admin que herede de AbstractUser y con eso no tienes que usar la relación OneToOne y un modelo nuevo.
https://docs.djangoproject.com/en/1.11/topics/auth/customizing/#substituting-a-custom-user-model

Kevin Morales
Lo que pasa es que el campo
first_name
email
Lo que puedes mostrar es el nombre de usuario con
user.username
user.first_name
Pero ese campo ya lo maneja Django en la seccion de su admin