from django.contrib import admin
from cfp.models import CallForPaper, PaperApplication, Applicant
from django.core import urlresolvers


class ApplicantAdmin(admin.ModelAdmin):
    readonly_fields = ('user',)
    list_display = ('full_name', 'about', 'biography', 'speaker_experience', 'github', 'twitter')
    fields = ('user', 'about', 'biography', 'speaker_experience', 'image')


class PaperApplicationAdmin(admin.ModelAdmin):
    list_display = ('title', 'link_to_applicant', 'about', 'abstract', 'skill_level', 'duration')
    readonly_fields = ('cfp', 'applicant')
    fields = ('cfp', 'applicant', 'title', 'about', 'abstract', 'skill_level', 'duration')

    def link_to_applicant(self, obj):
        link = urlresolvers.reverse("admin:cfp_applicant_change", args=[obj.applicant.id])
        return u'<a href="%s">%s</a>' % (link, obj.applicant)
    link_to_applicant.allow_tags = True

admin.site.register(CallForPaper)
admin.site.register(Applicant, ApplicantAdmin)
admin.site.register(PaperApplication, PaperApplicationAdmin)

from django.contrib import admin
from cfp.models import CallForPaper, PaperApplication, Applicant
from django.core import urlresolvers


class ApplicantAdmin(admin.ModelAdmin):
    list_display = ('user', 'full_name', 'about', 'biography', 'speaker_experience', 'github', 'twitter')
    fields = ('user', 'about', 'biography', 'speaker_experience', 'image')


class PaperApplicationAdmin(admin.ModelAdmin):
    list_display = ('title', 'link_to_applicant', 'about', 'abstract', 'skill_level', 'duration')
    readonly_fields = ('cfp', 'applicant')
    fields = ('cfp', 'applicant', 'title', 'about', 'abstract', 'skill_level', 'duration')

    def link_to_applicant(self, obj):
        link = urlresolvers.reverse("admin:cfp_applicant_change", args=[obj.applicant.id])
        return u'<a href="%s">%s</a>' % (link, obj.applicant)
    link_to_applicant.allow_tags = True

admin.site.register(CallForPaper)
admin.site.register(Applicant, ApplicantAdmin)
admin.site.register(PaperApplication, PaperApplicationAdmin)

Remove user from readonly fields
Remove user from readonly fields

So that we can add Applicants from the admin interface.

  from django.contrib import admin
  from cfp.models import CallForPaper, PaperApplication, Applicant
  from django.core import urlresolvers
  
  
  class ApplicantAdmin(admin.ModelAdmin):
-     readonly_fields = ('user',)
-     list_display = ('full_name', 'about', 'biography', 'speaker_experience', 'github', 'twitter')
+     list_display = ('user', 'full_name', 'about', 'biography', 'speaker_experience', 'github', 'twitter')
      fields = ('user', 'about', 'biography', 'speaker_experience', 'image')
  
  
  class PaperApplicationAdmin(admin.ModelAdmin):
      list_display = ('title', 'link_to_applicant', 'about', 'abstract', 'skill_level', 'duration')
      readonly_fields = ('cfp', 'applicant')
      fields = ('cfp', 'applicant', 'title', 'about', 'abstract', 'skill_level', 'duration')
  
      def link_to_applicant(self, obj):
          link = urlresolvers.reverse("admin:cfp_applicant_change", args=[obj.applicant.id])
          return u'<a href="%s">%s</a>' % (link, obj.applicant)
      link_to_applicant.allow_tags = True
  
  admin.site.register(CallForPaper)
  admin.site.register(Applicant, ApplicantAdmin)
  admin.site.register(PaperApplication, PaperApplicationAdmin)
  
Remove user from readonly fields
## Code Before:
from django.contrib import admin
from cfp.models import CallForPaper, PaperApplication, Applicant
from django.core import urlresolvers


class ApplicantAdmin(admin.ModelAdmin):
    readonly_fields = ('user',)
    list_display = ('full_name', 'about', 'biography', 'speaker_experience', 'github', 'twitter')
    fields = ('user', 'about', 'biography', 'speaker_experience', 'image')


class PaperApplicationAdmin(admin.ModelAdmin):
    list_display = ('title', 'link_to_applicant', 'about', 'abstract', 'skill_level', 'duration')
    readonly_fields = ('cfp', 'applicant')
    fields = ('cfp', 'applicant', 'title', 'about', 'abstract', 'skill_level', 'duration')

    def link_to_applicant(self, obj):
        link = urlresolvers.reverse("admin:cfp_applicant_change", args=[obj.applicant.id])
        return u'<a href="%s">%s</a>' % (link, obj.applicant)
    link_to_applicant.allow_tags = True

admin.site.register(CallForPaper)
admin.site.register(Applicant, ApplicantAdmin)
admin.site.register(PaperApplication, PaperApplicationAdmin)

## Instruction:
Remove user from readonly fields
## Code After:
from django.contrib import admin
from cfp.models import CallForPaper, PaperApplication, Applicant
from django.core import urlresolvers


class ApplicantAdmin(admin.ModelAdmin):
    list_display = ('user', 'full_name', 'about', 'biography', 'speaker_experience', 'github', 'twitter')
    fields = ('user', 'about', 'biography', 'speaker_experience', 'image')


class PaperApplicationAdmin(admin.ModelAdmin):
    list_display = ('title', 'link_to_applicant', 'about', 'abstract', 'skill_level', 'duration')
    readonly_fields = ('cfp', 'applicant')
    fields = ('cfp', 'applicant', 'title', 'about', 'abstract', 'skill_level', 'duration')

    def link_to_applicant(self, obj):
        link = urlresolvers.reverse("admin:cfp_applicant_change", args=[obj.applicant.id])
        return u'<a href="%s">%s</a>' % (link, obj.applicant)
    link_to_applicant.allow_tags = True

admin.site.register(CallForPaper)
admin.site.register(Applicant, ApplicantAdmin)
admin.site.register(PaperApplication, PaperApplicationAdmin)
