# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.contrib import admin

from .models import ExtraInfo


class ExtraInfoAdmin(admin.ModelAdmin):
    """
    Admin interface for ExtraInfo model.
    """

    readonly_fields = (
        'user',
    )

    class Meta(object):
        model = ExtraInfo

admin.site.register(ExtraInfo, ExtraInfoAdmin)

# -*- coding: utf-8 -*-
from __future__ import unicode_literals

from django.contrib import admin

from .models import ExtraInfo


class ExtraInfoAdmin(admin.ModelAdmin):
    """
    Admin interface for ExtraInfo model.
    """

    list_display = (
        'user',
        'get_email',
        'last_name',
        'first_name',
    )
    readonly_fields = (
        'user',
    )
    search_fields = (
        'user__username',
        'user__email',
        'last_name',
        'first_name',
    )

    def get_email(self, obj):
        return obj.user.email
    get_email.short_description = 'Email address'

    class Meta(object):
        model = ExtraInfo

admin.site.register(ExtraInfo, ExtraInfoAdmin)

Make ExtraInfo list user-friendly in Django Admin
Make ExtraInfo list user-friendly in Django Admin

`Register_cme/extrainfo` in Django Admin was previously displaying users
as `ExtraInfo` objects which admins had to click on individually to see
each user's information. Each user is now displayed with fields:
username, email, last and first name. Username is clickable to view more
information. Added search bar enables search for users matching query
for username, email, last and first name.
