prompt: You will be provided with a partial code base and an issue statement explaining a problem to resolve.
  <issue>
  From django administration page, in Portal, can't access Teachers or Students
  Trying to access a Student or Teacher from the administration page leads to an error:
  Failed to load resource: the server responded with a status of 500 (OK)
  
  
  </issue>
  <code>
  [start of portal/admin.py]
  1 # -*- coding: utf-8 -*-
  2 # Code for Life
  3 #
  4 # Copyright (C) 2016, Ocado Innovation Limited
  5 #
  6 # This program is free software: you can redistribute it and/or modify
  7 # it under the terms of the GNU Affero General Public License as
  8 # published by the Free Software Foundation, either version 3 of the
  9 # License, or (at your option) any later version.
  10 #
  11 # This program is distributed in the hope that it will be useful,
  12 # but WITHOUT ANY WARRANTY; without even the implied warranty of
  13 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14 # GNU Affero General Public License for more details.
  15 #
  16 # You should have received a copy of the GNU Affero General Public License
  17 # along with this program.  If not, see <http://www.gnu.org/licenses/>.
  18 #
  19 # ADDITIONAL TERMS – Section 7 GNU General Public Licence
  20 #
  21 # This licence does not grant any right, title or interest in any “Ocado” logos,
  22 # trade names or the trademark “Ocado” or any other trademarks or domain names
  23 # owned by Ocado Innovation Limited or the Ocado group of companies or any other
  24 # distinctive brand features of “Ocado” as may be secured from time to time. You
  25 # must not distribute any modification of this program using the trademark
  26 # “Ocado” or claim any affiliation or association with Ocado or its employees.
  27 #
  28 # You are not authorised to use the name Ocado (or any of its trade names) or
  29 # the names of any author or contributor in advertising or for publicity purposes
  30 # pertaining to the distribution of this program, without the prior written
  31 # authorisation of Ocado.
  32 #
  33 # Any propagation, distribution or conveyance of this program must include this
  34 # copyright notice and these terms. You must not misrepresent the origins of this
  35 # program; modified versions of the program must be marked as such and not
  36 # identified as the original program.
  37 from django.contrib import admin
  38 from django.contrib.auth.models import User
  39 from django.contrib.auth.admin import UserAdmin
  40 
  41 
  42 from portal.models import Class, Student, Guardian, Teacher, School, UserProfile, FrontPageNews, EmailVerification
  43 
  44 
  45 class ClassAdmin(admin.ModelAdmin):
  46     search_fields = ['name', 'teacher__new_user__first_name', 'teacher__new_user__last_name']
  47     list_filter = ['teacher']
  48 
  49 
  50 class SchoolAdmin(admin.ModelAdmin):
  51     search_fields = ['name', 'country', 'postcode', 'town']
  52     list_filter = ['postcode', 'country']
  53 
  54 
  55 class StudentAdmin(admin.ModelAdmin):
  56     search_fields = ['new_user__first_name', 'new_user__last_name']
  57     list_filter = ['class_field', 'class_field__teacher']
  58 
  59 
  60 class TeacherAdmin(admin.ModelAdmin):
  61     search_fields = ['new_user__first_name', 'new_user__last_name']
  62     list_filter = ['school']
  63 
  64 
  65 class UserProfileAdmin(admin.ModelAdmin):
  66     search_fields = ['user__first_name', 'user__last_name', 'new_username', 'user__date_joined']
  67     list_filter = ['user__date_joined']
  68     list_display = ['user', 'joined_recently']
  69 
  70 
  71 class EmailVerificationAdmin(admin.ModelAdmin):
  72     search_fields = ['new_user']
  73 
  74 
  75 UserAdmin.list_display += ('date_joined',)
  76 UserAdmin.list_filter += ('date_joined',)
  77 
  78 
  79 admin.site.register(Class, ClassAdmin)
  80 admin.site.register(Student, StudentAdmin)
  81 admin.site.register(Guardian)
  82 admin.site.register(Teacher, TeacherAdmin)
  83 admin.site.register(School, SchoolAdmin)
  84 admin.site.unregister(User)
  85 admin.site.register(User, UserAdmin)
  86 admin.site.register(UserProfile, UserProfileAdmin)
  87 admin.site.register(FrontPageNews)
  88 admin.site.register(EmailVerification, EmailVerificationAdmin)
  89
  [end of portal/admin.py]
  </code>
  
  I need you to solve this issue by generating a single patch file that I can apply directly to this repository using git apply. Please respond with a single patch file in the following format.
  <patch>
  diff --git a/file.py b/file.py
  --- a/file.py
  +++ b/file.py
  @@ -1,27 +1,35 @@
   def euclidean(a, b):
  -    while b:
  -        a, b = b, a % b
  -    return a
  +    if b == 0:
  +        return a
  +    return euclidean(b, a % b)
   
   
   def bresenham(x0, y0, x1, y1):
       points = []
       dx = abs(x1 - x0)
       dy = abs(y1 - y0)
  -    sx = 1 if x0 < x1 else -1
  -    sy = 1 if y0 < y1 else -1
  -    err = dx - dy
  +    x, y = x0, y0
  +    sx = -1 if x0 > x1 else 1
  +    sy = -1 if y0 > y1 else 1
   
  -    while True:
  -        points.append((x0, y0))
  -        if x0 == x1 and y0 == y1:
  -            break
  -        e2 = 2 * err
  -        if e2 > -dy:
  -            err -= dy
  -            x0 += sx
  -        if e2 < dx:
  -            err += dx
  -            y0 += sy
  +    if dx > dy:
  +        err = dx / 2.0
  +        while x != x1:
  +            points.append((x, y))
  +            err -= dy
  +            if err < 0:
  +                y += sy
  +                err += dx
  +            x += sx
  +    else:
  +        err = dy / 2.0
  +        while y != y1:
  +            points.append((x, y))
  +            err -= dx
  +            if err < 0:
  +                x += sx
  +                err += dy
  +            y += sy
  +
  +    points.append((x, y))
       return points
  
  </patch>
golden_diff: diff --git a/portal/admin.py b/portal/admin.py
  --- a/portal/admin.py
  +++ b/portal/admin.py
  @@ -45,6 +45,7 @@
   class ClassAdmin(admin.ModelAdmin):
       search_fields = ['name', 'teacher__new_user__first_name', 'teacher__new_user__last_name']
       list_filter = ['teacher']
  +    readonly_fields = ['teacher']
   
   
   class SchoolAdmin(admin.ModelAdmin):
  @@ -55,17 +56,22 @@
   class StudentAdmin(admin.ModelAdmin):
       search_fields = ['new_user__first_name', 'new_user__last_name']
       list_filter = ['class_field', 'class_field__teacher']
  +    readonly_fields = ['user', 'new_user']
  +    raw_id_fields = ['class_field', 'pending_class_request']
   
   
   class TeacherAdmin(admin.ModelAdmin):
       search_fields = ['new_user__first_name', 'new_user__last_name']
       list_filter = ['school']
  +    readonly_fields = ['user', 'new_user']
  +    raw_id_fields = ['school', 'pending_join_request']
   
   
   class UserProfileAdmin(admin.ModelAdmin):
       search_fields = ['user__first_name', 'user__last_name', 'new_username', 'user__date_joined']
       list_filter = ['user__date_joined']
       list_display = ['user', 'joined_recently']
  +    readonly_fields = ['user']
   
   
   class EmailVerificationAdmin(admin.ModelAdmin):
  
verification_info: {"golden_diff": "diff --git a/portal/admin.py b/portal/admin.py\n--- a/portal/admin.py\n+++ b/portal/admin.py\n@@ -45,6 +45,7 @@\n class ClassAdmin(admin.ModelAdmin):\n     search_fields = ['name', 'teacher__new_user__first_name', 'teacher__new_user__last_name']\n     list_filter = ['teacher']\n+    readonly_fields = ['teacher']\n \n \n class SchoolAdmin(admin.ModelAdmin):\n@@ -55,17 +56,22 @@\n class StudentAdmin(admin.ModelAdmin):\n     search_fields = ['new_user__first_name', 'new_user__last_name']\n     list_filter = ['class_field', 'class_field__teacher']\n+    readonly_fields = ['user', 'new_user']\n+    raw_id_fields = ['class_field', 'pending_class_request']\n \n \n class TeacherAdmin(admin.ModelAdmin):\n     search_fields = ['new_user__first_name', 'new_user__last_name']\n     list_filter = ['school']\n+    readonly_fields = ['user', 'new_user']\n+    raw_id_fields = ['school', 'pending_join_request']\n \n \n class UserProfileAdmin(admin.ModelAdmin):\n     search_fields = ['user__first_name', 'user__last_name', 'new_username', 'user__date_joined']\n     list_filter = ['user__date_joined']\n     list_display = ['user', 'joined_recently']\n+    readonly_fields = ['user']\n \n \n class EmailVerificationAdmin(admin.ModelAdmin):\n", "issue": "From django administration page, in Portal, can't access Teachers or Students\nTrying to access a Student or Teacher from the administration page leads to an error:\nFailed to load resource: the server responded with a status of 500 (OK)\n\n", "before_files": [{"content": "# -*- coding: utf-8 -*-\n# Code for Life\n#\n# Copyright (C) 2016, Ocado Innovation Limited\n#\n# This program is free software: you can redistribute it and/or modify\n# it under the terms of the GNU Affero General Public License as\n# published by the Free Software Foundation, either version 3 of the\n# License, or (at your option) any later version.\n#\n# This program is distributed in the hope that it will be useful,\n# but WITHOUT ANY WARRANTY; without even the implied warranty of\n# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the\n# GNU Affero General Public License for more details.\n#\n# You should have received a copy of the GNU Affero General Public License\n# along with this program.  If not, see <http://www.gnu.org/licenses/>.\n#\n# ADDITIONAL TERMS \u2013 Section 7 GNU General Public Licence\n#\n# This licence does not grant any right, title or interest in any \u201cOcado\u201d logos,\n# trade names or the trademark \u201cOcado\u201d or any other trademarks or domain names\n# owned by Ocado Innovation Limited or the Ocado group of companies or any other\n# distinctive brand features of \u201cOcado\u201d as may be secured from time to time. You\n# must not distribute any modification of this program using the trademark\n# \u201cOcado\u201d or claim any affiliation or association with Ocado or its employees.\n#\n# You are not authorised to use the name Ocado (or any of its trade names) or\n# the names of any author or contributor in advertising or for publicity purposes\n# pertaining to the distribution of this program, without the prior written\n# authorisation of Ocado.\n#\n# Any propagation, distribution or conveyance of this program must include this\n# copyright notice and these terms. You must not misrepresent the origins of this\n# program; modified versions of the program must be marked as such and not\n# identified as the original program.\nfrom django.contrib import admin\nfrom django.contrib.auth.models import User\nfrom django.contrib.auth.admin import UserAdmin\n\n\nfrom portal.models import Class, Student, Guardian, Teacher, School, UserProfile, FrontPageNews, EmailVerification\n\n\nclass ClassAdmin(admin.ModelAdmin):\n    search_fields = ['name', 'teacher__new_user__first_name', 'teacher__new_user__last_name']\n    list_filter = ['teacher']\n\n\nclass SchoolAdmin(admin.ModelAdmin):\n    search_fields = ['name', 'country', 'postcode', 'town']\n    list_filter = ['postcode', 'country']\n\n\nclass StudentAdmin(admin.ModelAdmin):\n    search_fields = ['new_user__first_name', 'new_user__last_name']\n    list_filter = ['class_field', 'class_field__teacher']\n\n\nclass TeacherAdmin(admin.ModelAdmin):\n    search_fields = ['new_user__first_name', 'new_user__last_name']\n    list_filter = ['school']\n\n\nclass UserProfileAdmin(admin.ModelAdmin):\n    search_fields = ['user__first_name', 'user__last_name', 'new_username', 'user__date_joined']\n    list_filter = ['user__date_joined']\n    list_display = ['user', 'joined_recently']\n\n\nclass EmailVerificationAdmin(admin.ModelAdmin):\n    search_fields = ['new_user']\n\n\nUserAdmin.list_display += ('date_joined',)\nUserAdmin.list_filter += ('date_joined',)\n\n\nadmin.site.register(Class, ClassAdmin)\nadmin.site.register(Student, StudentAdmin)\nadmin.site.register(Guardian)\nadmin.site.register(Teacher, TeacherAdmin)\nadmin.site.register(School, SchoolAdmin)\nadmin.site.unregister(User)\nadmin.site.register(User, UserAdmin)\nadmin.site.register(UserProfile, UserProfileAdmin)\nadmin.site.register(FrontPageNews)\nadmin.site.register(EmailVerification, EmailVerificationAdmin)\n", "path": "portal/admin.py"}]}