from django.contrib import admin

from markedit.admin import MarkEditAdmin

from symposion.speakers.models import Speaker


class SpeakerAdmin(MarkEditAdmin):
    list_display = ["name", "email", "created", "twitter_username"]
    search_fields = ["name", "twitter_username"]

    class MarkEdit:
        fields = ['biography', ]
        options = {
            'preview': 'below'
        }

admin.site.register(Speaker, SpeakerAdmin)

from django.contrib import admin

from markedit.admin import MarkEditAdmin

from symposion.speakers.models import Speaker


class SpeakerAdmin(MarkEditAdmin):
    list_display = ["name", "email", "created", "twitter_username"]
    raw_id_fields = ["user"]
    search_fields = ["name", "twitter_username"]

    class MarkEdit:
        fields = ['biography', ]
        options = {
            'preview': 'below'
        }

admin.site.register(Speaker, SpeakerAdmin)

Fix user selection for speaker add
Fix user selection for speaker add

When adding a speaker in the admin, the staff person had to
pick a user from a huge dropdown with all the users, unsorted.

Change 'user' to a raw id field, meaning to pick a user, the staff member clicks a magnifying glass icon next to the field and gets a popup listing all the users in an admin list page with sortable columns and search.

  from django.contrib import admin
  
  from markedit.admin import MarkEditAdmin
  
  from symposion.speakers.models import Speaker
  
  
  class SpeakerAdmin(MarkEditAdmin):
      list_display = ["name", "email", "created", "twitter_username"]
+     raw_id_fields = ["user"]
      search_fields = ["name", "twitter_username"]
  
      class MarkEdit:
          fields = ['biography', ]
          options = {
              'preview': 'below'
          }
  
  admin.site.register(Speaker, SpeakerAdmin)
  
Fix user selection for speaker add
## Code Before:
from django.contrib import admin

from markedit.admin import MarkEditAdmin

from symposion.speakers.models import Speaker


class SpeakerAdmin(MarkEditAdmin):
    list_display = ["name", "email", "created", "twitter_username"]
    search_fields = ["name", "twitter_username"]

    class MarkEdit:
        fields = ['biography', ]
        options = {
            'preview': 'below'
        }

admin.site.register(Speaker, SpeakerAdmin)

## Instruction:
Fix user selection for speaker add
## Code After:
from django.contrib import admin

from markedit.admin import MarkEditAdmin

from symposion.speakers.models import Speaker


class SpeakerAdmin(MarkEditAdmin):
    list_display = ["name", "email", "created", "twitter_username"]
    raw_id_fields = ["user"]
    search_fields = ["name", "twitter_username"]

    class MarkEdit:
        fields = ['biography', ]
        options = {
            'preview': 'below'
        }

admin.site.register(Speaker, SpeakerAdmin)
