DT
Size: a a a
DT
IT
МВ
МВ
class ProfileInlineAdmin(admin.StackedInline):
model = Profile
can_delete = False
verbose_name_plural = 'Профиль юзера'
class UserAdmin(BaseUserAdmin):
inlines = (ProfileInlineAdmin,)
list_display = ('username', profile.tg_id <- что вместо этого)
DT
МВ
DT
DT
МВ
МВ
DT
МВ
<class 'polls.admin.UserAdmin'>: (admin.E108) The value of 'list_display[1]' refers to 'Profile__tg_id', which is not a callable, an attribute of 'UserAdmin', or an attribute or
method on 'auth.User'.
МВ
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
tg_id = models.CharField(max_length=15, blank=True)
def __str__(self):
return self.user.username
DT
МВ
<class 'polls.admin.UserAdmin'>: (admin.E108) The value of 'list_display[1]' refers to 'profile__tg_id', which is not a callable, an attribute of 'UserAdmin', or an attribute or
method on 'auth.User'.
МВ
D
list_display = ('username', 'get_tg_profile_id')
def get_tg_profile_id(self, obj):
return obj.profile.tg_id
get_tg_profile_id.short_description = 'Tg Profile ID'
D
МВ
DT