prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Admin commands broken
  Please check all the admin commands (use `make` on its own to get a list):
  
  ```
  $ make airports
  
  /Users/gvwilson/anaconda/envs/py3k/lib/python3.3/site-packages/crispy_forms/utils.py:25: RemovedInDjango19Warning: memoize wrapper is deprecated and will be removed in Django 1.9. Use django.utils.lru_cache instead.
    default_field_template = memoize(default_field_template, {}, 1)
  
  Traceback (most recent call last):
    File "manage.py", line 10, in <module>
      execute_from_command_line(sys.argv)
    File "/Users/gvwilson/anaconda/envs/py3k/lib/python3.3/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
      utility.execute()
    File "/Users/gvwilson/anaconda/envs/py3k/lib/python3.3/site-packages/django/core/management/__init__.py", line 330, in execute
      self.fetch_command(subcommand).run_from_argv(self.argv)
    File "/Users/gvwilson/anaconda/envs/py3k/lib/python3.3/site-packages/django/core/management/__init__.py", line 190, in fetch_command
      klass = load_command_class(app_name, subcommand)
    File "/Users/gvwilson/anaconda/envs/py3k/lib/python3.3/site-packages/django/core/management/__init__.py", line 40, in load_command_class
      module = import_module('%s.management.commands.%s' % (app_name, name))
    File "/Users/gvwilson/anaconda/envs/py3k/lib/python3.3/importlib/__init__.py", line 90, in import_module
      return _bootstrap._gcd_import(name[level:], package, level)
    File "<frozen importlib._bootstrap>", line 1582, in _gcd_import
    File "<frozen importlib._bootstrap>", line 1563, in _find_and_load
    File "<frozen importlib._bootstrap>", line 1530, in _find_and_load_unlocked
    File "<frozen importlib._bootstrap>", line 584, in _check_name_wrapper
    File "<frozen importlib._bootstrap>", line 1022, in load_module
    File "<frozen importlib._bootstrap>", line 1003, in load_module
    File "<frozen importlib._bootstrap>", line 560, in module_for_loader_wrapper
    File "<frozen importlib._bootstrap>", line 868, in _load_module
    File "<frozen importlib._bootstrap>", line 313, in _call_with_frames_removed
    File "/Users/gvwilson/s/amy/workshops/management/commands/export_airports.py", line 3, in <module>
      from workshops.views import _export_instructors
  ImportError: cannot import name _export_instructors
  make: *** [airports] Error 1
  ```
  
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `workshops/management/commands/export_airports.py`
  Content:
  ```
  1 import yaml
  2 from django.core.management.base import BaseCommand, CommandError
  3 from workshops.views import _export_instructors
  4 
  5 class Command(BaseCommand):
  6     args = 'no arguments'
  7     help = 'Display YAML for airports.'
  8 
  9     def handle(self, *args, **options):
  10         print(yaml.dump(_export_instructors()).rstrip())
  11
  ```
  
  Path: `workshops/management/commands/export_badges.py`
  Content:
  ```
  1 import yaml
  2 from django.core.management.base import BaseCommand, CommandError
  3 from workshops.views import _export_badges
  4 
  5 class Command(BaseCommand):
  6     args = 'no arguments'
  7     help = 'Display YAML for badges.'
  8 
  9     def handle(self, *args, **options):
  10         print(yaml.dump(_export_badges()).rstrip())
  11
  ```
  
  Path: `api/views.py`
  Content:
  ```
  1 from django.db.models import Q
  2 from rest_framework.generics import ListAPIView
  3 from rest_framework.permissions import IsAuthenticatedOrReadOnly
  4 from rest_framework.response import Response
  5 from rest_framework.reverse import reverse
  6 from rest_framework.views import APIView
  7 
  8 from workshops.models import Badge, Airport, Event
  9 
  10 from .serializers import (
  11     ExportBadgesSerializer,
  12     ExportInstructorLocationsSerializer,
  13     EventSerializer,
  14 )
  15 
  16 
  17 class ApiRoot(APIView):
  18     def get(self, request, format=None):
  19         return Response({
  20             'export-badges': reverse('api:export-badges', request=request,
  21                                      format=format),
  22             'export-instructors': reverse('api:export-instructors',
  23                                           request=request, format=format),
  24             'events-published': reverse('api:events-published',
  25                                         request=request, format=format),
  26         })
  27 
  28 
  29 class ExportBadgesView(APIView):
  30     """List all badges and people who have them."""
  31     permission_classes = (IsAuthenticatedOrReadOnly, )
  32 
  33     def get(self, request, format=None):
  34         badges = Badge.objects.prefetch_related('person_set')
  35         serializer = ExportBadgesSerializer(badges, many=True)
  36         return Response(serializer.data)
  37 
  38 
  39 class ExportInstructorLocationsView(APIView):
  40     """List all airports and instructors located near them."""
  41     permission_classes = (IsAuthenticatedOrReadOnly, )
  42 
  43     def get(self, request, format=None):
  44         # TODO: return only people marked as instructors?
  45         airports = Airport.objects.exclude(person=None) \
  46                                   .prefetch_related('person_set')
  47         serializer = ExportInstructorLocationsSerializer(airports, many=True)
  48         return Response(serializer.data)
  49 
  50 
  51 class ListEvents(APIView):
  52     # I wanted to use ListAPIView, but it had problems with the way we test
  53     # this code... Basically ListAPIView uses pagination, and pagination
  54     # requires existing Request object - something we're faking in part of the
  55     # tests (request = None).
  56     serializer_class = EventSerializer
  57     permission_classes = (IsAuthenticatedOrReadOnly, )
  58     queryset = None  # override this in the subclass
  59 
  60     def get(self, request, format=None):
  61         objects = self.queryset.all()
  62         serializer = self.serializer_class(objects, many=True)
  63         return Response(serializer.data)
  64 
  65 
  66 class PublishedEvents(ListEvents):
  67     # only events that have both a starting date and a URL
  68     queryset = Event.objects.exclude(
  69         Q(start__isnull=True) | Q(url__isnull=True)
  70     ).order_by('-start')
  71
  ```
  --- END FILES ---
  
  Please first localize the bug based on the issue statement, and then generate a patch according to the `git diff` format fenced by three backticks.
  
  Here is an example:
  
  ```diff
  diff --git a/examples/server_async.py b/examples/server_async.py
  --- a/examples/server_async.py
  +++ b/examples/server_async.py
  @@ -313,4 +313,4 @@
   
   
   if __name__ == "__main__":
  -    asyncio.run(run_async_server("."), debug=True)
  +    asyncio.run(run_async_server(), debug=True)
  diff --git a/examples/server_sync.py b/examples/server_sync.py
  --- a/examples/server_sync.py
  +++ b/examples/server_sync.py
  @@ -313,5 +313,5 @@
   
   
   if __name__ == "__main__":
  -    server = run_sync_server(".")
  +    server = run_sync_server()
       server.shutdown()
  
  ```
  
golden_diff: diff --git a/api/views.py b/api/views.py
  --- a/api/views.py
  +++ b/api/views.py
  @@ -26,45 +26,31 @@
           })
   
   
  -class ExportBadgesView(APIView):
  +class ExportBadgesView(ListAPIView):
       """List all badges and people who have them."""
       permission_classes = (IsAuthenticatedOrReadOnly, )
  +    paginator = None  # disable pagination
   
  -    def get(self, request, format=None):
  -        badges = Badge.objects.prefetch_related('person_set')
  -        serializer = ExportBadgesSerializer(badges, many=True)
  -        return Response(serializer.data)
  +    queryset = Badge.objects.prefetch_related('person_set')
  +    serializer_class = ExportBadgesSerializer
   
   
  -class ExportInstructorLocationsView(APIView):
  +class ExportInstructorLocationsView(ListAPIView):
       """List all airports and instructors located near them."""
       permission_classes = (IsAuthenticatedOrReadOnly, )
  +    paginator = None  # disable pagination
   
  -    def get(self, request, format=None):
  -        # TODO: return only people marked as instructors?
  -        airports = Airport.objects.exclude(person=None) \
  -                                  .prefetch_related('person_set')
  -        serializer = ExportInstructorLocationsSerializer(airports, many=True)
  -        return Response(serializer.data)
  +    queryset = Airport.objects.exclude(person=None) \
  +                              .prefetch_related('person_set')
  +    serializer_class = ExportInstructorLocationsSerializer
   
   
  -class ListEvents(APIView):
  -    # I wanted to use ListAPIView, but it had problems with the way we test
  -    # this code... Basically ListAPIView uses pagination, and pagination
  -    # requires existing Request object - something we're faking in part of the
  -    # tests (request = None).
  -    serializer_class = EventSerializer
  +class PublishedEvents(ListAPIView):
  +    # only events that have both a starting date and a URL
       permission_classes = (IsAuthenticatedOrReadOnly, )
  -    queryset = None  # override this in the subclass
  +    paginator = None  # disable pagination
   
  -    def get(self, request, format=None):
  -        objects = self.queryset.all()
  -        serializer = self.serializer_class(objects, many=True)
  -        return Response(serializer.data)
  -
  -
  -class PublishedEvents(ListEvents):
  -    # only events that have both a starting date and a URL
  +    serializer_class = EventSerializer
       queryset = Event.objects.exclude(
           Q(start__isnull=True) | Q(url__isnull=True)
       ).order_by('-start')
  diff --git a/workshops/management/commands/export_airports.py b/workshops/management/commands/export_airports.py
  --- a/workshops/management/commands/export_airports.py
  +++ b/workshops/management/commands/export_airports.py
  @@ -1,10 +1,14 @@
  -import yaml
  -from django.core.management.base import BaseCommand, CommandError
  -from workshops.views import _export_instructors
  +from django.core.management.base import BaseCommand
  +from django.core.urlresolvers import reverse
  +from rest_framework.test import APIClient
  +
   
   class Command(BaseCommand):
       args = 'no arguments'
       help = 'Display YAML for airports.'
   
       def handle(self, *args, **options):
  -        print(yaml.dump(_export_instructors()).rstrip())
  +        client = APIClient()
  +        response = client.get(reverse('api:export-instructors'),
  +                              {'format': 'yaml'})
  +        print(response.content.decode('utf-8'))
  diff --git a/workshops/management/commands/export_badges.py b/workshops/management/commands/export_badges.py
  --- a/workshops/management/commands/export_badges.py
  +++ b/workshops/management/commands/export_badges.py
  @@ -1,10 +1,14 @@
  -import yaml
  -from django.core.management.base import BaseCommand, CommandError
  -from workshops.views import _export_badges
  +from django.core.management.base import BaseCommand
  +from django.core.urlresolvers import reverse
  +from rest_framework.test import APIClient
  +
   
   class Command(BaseCommand):
       args = 'no arguments'
       help = 'Display YAML for badges.'
   
       def handle(self, *args, **options):
  -        print(yaml.dump(_export_badges()).rstrip())
  +        client = APIClient()
  +        response = client.get(reverse('api:export-badges'),
  +                              {'format': 'yaml'})
  +        print(response.content.decode('utf-8'))
  
verification_info: {"golden_diff": "diff --git a/api/views.py b/api/views.py\n--- a/api/views.py\n+++ b/api/views.py\n@@ -26,45 +26,31 @@\n         })\n \n \n-class ExportBadgesView(APIView):\n+class ExportBadgesView(ListAPIView):\n     \"\"\"List all badges and people who have them.\"\"\"\n     permission_classes = (IsAuthenticatedOrReadOnly, )\n+    paginator = None  # disable pagination\n \n-    def get(self, request, format=None):\n-        badges = Badge.objects.prefetch_related('person_set')\n-        serializer = ExportBadgesSerializer(badges, many=True)\n-        return Response(serializer.data)\n+    queryset = Badge.objects.prefetch_related('person_set')\n+    serializer_class = ExportBadgesSerializer\n \n \n-class ExportInstructorLocationsView(APIView):\n+class ExportInstructorLocationsView(ListAPIView):\n     \"\"\"List all airports and instructors located near them.\"\"\"\n     permission_classes = (IsAuthenticatedOrReadOnly, )\n+    paginator = None  # disable pagination\n \n-    def get(self, request, format=None):\n-        # TODO: return only people marked as instructors?\n-        airports = Airport.objects.exclude(person=None) \\\n-                                  .prefetch_related('person_set')\n-        serializer = ExportInstructorLocationsSerializer(airports, many=True)\n-        return Response(serializer.data)\n+    queryset = Airport.objects.exclude(person=None) \\\n+                              .prefetch_related('person_set')\n+    serializer_class = ExportInstructorLocationsSerializer\n \n \n-class ListEvents(APIView):\n-    # I wanted to use ListAPIView, but it had problems with the way we test\n-    # this code... Basically ListAPIView uses pagination, and pagination\n-    # requires existing Request object - something we're faking in part of the\n-    # tests (request = None).\n-    serializer_class = EventSerializer\n+class PublishedEvents(ListAPIView):\n+    # only events that have both a starting date and a URL\n     permission_classes = (IsAuthenticatedOrReadOnly, )\n-    queryset = None  # override this in the subclass\n+    paginator = None  # disable pagination\n \n-    def get(self, request, format=None):\n-        objects = self.queryset.all()\n-        serializer = self.serializer_class(objects, many=True)\n-        return Response(serializer.data)\n-\n-\n-class PublishedEvents(ListEvents):\n-    # only events that have both a starting date and a URL\n+    serializer_class = EventSerializer\n     queryset = Event.objects.exclude(\n         Q(start__isnull=True) | Q(url__isnull=True)\n     ).order_by('-start')\ndiff --git a/workshops/management/commands/export_airports.py b/workshops/management/commands/export_airports.py\n--- a/workshops/management/commands/export_airports.py\n+++ b/workshops/management/commands/export_airports.py\n@@ -1,10 +1,14 @@\n-import yaml\n-from django.core.management.base import BaseCommand, CommandError\n-from workshops.views import _export_instructors\n+from django.core.management.base import BaseCommand\n+from django.core.urlresolvers import reverse\n+from rest_framework.test import APIClient\n+\n \n class Command(BaseCommand):\n     args = 'no arguments'\n     help = 'Display YAML for airports.'\n \n     def handle(self, *args, **options):\n-        print(yaml.dump(_export_instructors()).rstrip())\n+        client = APIClient()\n+        response = client.get(reverse('api:export-instructors'),\n+                              {'format': 'yaml'})\n+        print(response.content.decode('utf-8'))\ndiff --git a/workshops/management/commands/export_badges.py b/workshops/management/commands/export_badges.py\n--- a/workshops/management/commands/export_badges.py\n+++ b/workshops/management/commands/export_badges.py\n@@ -1,10 +1,14 @@\n-import yaml\n-from django.core.management.base import BaseCommand, CommandError\n-from workshops.views import _export_badges\n+from django.core.management.base import BaseCommand\n+from django.core.urlresolvers import reverse\n+from rest_framework.test import APIClient\n+\n \n class Command(BaseCommand):\n     args = 'no arguments'\n     help = 'Display YAML for badges.'\n \n     def handle(self, *args, **options):\n-        print(yaml.dump(_export_badges()).rstrip())\n+        client = APIClient()\n+        response = client.get(reverse('api:export-badges'),\n+                              {'format': 'yaml'})\n+        print(response.content.decode('utf-8'))\n", "issue": "Admin commands broken\nPlease check all the admin commands (use `make` on its own to get a list):\n\n```\n$ make airports\n\n/Users/gvwilson/anaconda/envs/py3k/lib/python3.3/site-packages/crispy_forms/utils.py:25: RemovedInDjango19Warning: memoize wrapper is deprecated and will be removed in Django 1.9. Use django.utils.lru_cache instead.\n  default_field_template = memoize(default_field_template, {}, 1)\n\nTraceback (most recent call last):\n  File \"manage.py\", line 10, in <module>\n    execute_from_command_line(sys.argv)\n  File \"/Users/gvwilson/anaconda/envs/py3k/lib/python3.3/site-packages/django/core/management/__init__.py\", line 338, in execute_from_command_line\n    utility.execute()\n  File \"/Users/gvwilson/anaconda/envs/py3k/lib/python3.3/site-packages/django/core/management/__init__.py\", line 330, in execute\n    self.fetch_command(subcommand).run_from_argv(self.argv)\n  File \"/Users/gvwilson/anaconda/envs/py3k/lib/python3.3/site-packages/django/core/management/__init__.py\", line 190, in fetch_command\n    klass = load_command_class(app_name, subcommand)\n  File \"/Users/gvwilson/anaconda/envs/py3k/lib/python3.3/site-packages/django/core/management/__init__.py\", line 40, in load_command_class\n    module = import_module('%s.management.commands.%s' % (app_name, name))\n  File \"/Users/gvwilson/anaconda/envs/py3k/lib/python3.3/importlib/__init__.py\", line 90, in import_module\n    return _bootstrap._gcd_import(name[level:], package, level)\n  File \"<frozen importlib._bootstrap>\", line 1582, in _gcd_import\n  File \"<frozen importlib._bootstrap>\", line 1563, in _find_and_load\n  File \"<frozen importlib._bootstrap>\", line 1530, in _find_and_load_unlocked\n  File \"<frozen importlib._bootstrap>\", line 584, in _check_name_wrapper\n  File \"<frozen importlib._bootstrap>\", line 1022, in load_module\n  File \"<frozen importlib._bootstrap>\", line 1003, in load_module\n  File \"<frozen importlib._bootstrap>\", line 560, in module_for_loader_wrapper\n  File \"<frozen importlib._bootstrap>\", line 868, in _load_module\n  File \"<frozen importlib._bootstrap>\", line 313, in _call_with_frames_removed\n  File \"/Users/gvwilson/s/amy/workshops/management/commands/export_airports.py\", line 3, in <module>\n    from workshops.views import _export_instructors\nImportError: cannot import name _export_instructors\nmake: *** [airports] Error 1\n```\n\n", "before_files": [{"content": "import yaml\nfrom django.core.management.base import BaseCommand, CommandError\nfrom workshops.views import _export_instructors\n\nclass Command(BaseCommand):\n    args = 'no arguments'\n    help = 'Display YAML for airports.'\n\n    def handle(self, *args, **options):\n        print(yaml.dump(_export_instructors()).rstrip())\n", "path": "workshops/management/commands/export_airports.py"}, {"content": "import yaml\nfrom django.core.management.base import BaseCommand, CommandError\nfrom workshops.views import _export_badges\n\nclass Command(BaseCommand):\n    args = 'no arguments'\n    help = 'Display YAML for badges.'\n\n    def handle(self, *args, **options):\n        print(yaml.dump(_export_badges()).rstrip())\n", "path": "workshops/management/commands/export_badges.py"}, {"content": "from django.db.models import Q\nfrom rest_framework.generics import ListAPIView\nfrom rest_framework.permissions import IsAuthenticatedOrReadOnly\nfrom rest_framework.response import Response\nfrom rest_framework.reverse import reverse\nfrom rest_framework.views import APIView\n\nfrom workshops.models import Badge, Airport, Event\n\nfrom .serializers import (\n    ExportBadgesSerializer,\n    ExportInstructorLocationsSerializer,\n    EventSerializer,\n)\n\n\nclass ApiRoot(APIView):\n    def get(self, request, format=None):\n        return Response({\n            'export-badges': reverse('api:export-badges', request=request,\n                                     format=format),\n            'export-instructors': reverse('api:export-instructors',\n                                          request=request, format=format),\n            'events-published': reverse('api:events-published',\n                                        request=request, format=format),\n        })\n\n\nclass ExportBadgesView(APIView):\n    \"\"\"List all badges and people who have them.\"\"\"\n    permission_classes = (IsAuthenticatedOrReadOnly, )\n\n    def get(self, request, format=None):\n        badges = Badge.objects.prefetch_related('person_set')\n        serializer = ExportBadgesSerializer(badges, many=True)\n        return Response(serializer.data)\n\n\nclass ExportInstructorLocationsView(APIView):\n    \"\"\"List all airports and instructors located near them.\"\"\"\n    permission_classes = (IsAuthenticatedOrReadOnly, )\n\n    def get(self, request, format=None):\n        # TODO: return only people marked as instructors?\n        airports = Airport.objects.exclude(person=None) \\\n                                  .prefetch_related('person_set')\n        serializer = ExportInstructorLocationsSerializer(airports, many=True)\n        return Response(serializer.data)\n\n\nclass ListEvents(APIView):\n    # I wanted to use ListAPIView, but it had problems with the way we test\n    # this code... Basically ListAPIView uses pagination, and pagination\n    # requires existing Request object - something we're faking in part of the\n    # tests (request = None).\n    serializer_class = EventSerializer\n    permission_classes = (IsAuthenticatedOrReadOnly, )\n    queryset = None  # override this in the subclass\n\n    def get(self, request, format=None):\n        objects = self.queryset.all()\n        serializer = self.serializer_class(objects, many=True)\n        return Response(serializer.data)\n\n\nclass PublishedEvents(ListEvents):\n    # only events that have both a starting date and a URL\n    queryset = Event.objects.exclude(\n        Q(start__isnull=True) | Q(url__isnull=True)\n    ).order_by('-start')\n", "path": "api/views.py"}], "after_files": [{"content": "from django.core.management.base import BaseCommand\nfrom django.core.urlresolvers import reverse\nfrom rest_framework.test import APIClient\n\n\nclass Command(BaseCommand):\n    args = 'no arguments'\n    help = 'Display YAML for airports.'\n\n    def handle(self, *args, **options):\n        client = APIClient()\n        response = client.get(reverse('api:export-instructors'),\n                              {'format': 'yaml'})\n        print(response.content.decode('utf-8'))\n", "path": "workshops/management/commands/export_airports.py"}, {"content": "from django.core.management.base import BaseCommand\nfrom django.core.urlresolvers import reverse\nfrom rest_framework.test import APIClient\n\n\nclass Command(BaseCommand):\n    args = 'no arguments'\n    help = 'Display YAML for badges.'\n\n    def handle(self, *args, **options):\n        client = APIClient()\n        response = client.get(reverse('api:export-badges'),\n                              {'format': 'yaml'})\n        print(response.content.decode('utf-8'))\n", "path": "workshops/management/commands/export_badges.py"}, {"content": "from django.db.models import Q\nfrom rest_framework.generics import ListAPIView\nfrom rest_framework.permissions import IsAuthenticatedOrReadOnly\nfrom rest_framework.response import Response\nfrom rest_framework.reverse import reverse\nfrom rest_framework.views import APIView\n\nfrom workshops.models import Badge, Airport, Event\n\nfrom .serializers import (\n    ExportBadgesSerializer,\n    ExportInstructorLocationsSerializer,\n    EventSerializer,\n)\n\n\nclass ApiRoot(APIView):\n    def get(self, request, format=None):\n        return Response({\n            'export-badges': reverse('api:export-badges', request=request,\n                                     format=format),\n            'export-instructors': reverse('api:export-instructors',\n                                          request=request, format=format),\n            'events-published': reverse('api:events-published',\n                                        request=request, format=format),\n        })\n\n\nclass ExportBadgesView(ListAPIView):\n    \"\"\"List all badges and people who have them.\"\"\"\n    permission_classes = (IsAuthenticatedOrReadOnly, )\n    paginator = None  # disable pagination\n\n    queryset = Badge.objects.prefetch_related('person_set')\n    serializer_class = ExportBadgesSerializer\n\n\nclass ExportInstructorLocationsView(ListAPIView):\n    \"\"\"List all airports and instructors located near them.\"\"\"\n    permission_classes = (IsAuthenticatedOrReadOnly, )\n    paginator = None  # disable pagination\n\n    queryset = Airport.objects.exclude(person=None) \\\n                              .prefetch_related('person_set')\n    serializer_class = ExportInstructorLocationsSerializer\n\n\nclass PublishedEvents(ListAPIView):\n    # only events that have both a starting date and a URL\n    permission_classes = (IsAuthenticatedOrReadOnly, )\n    paginator = None  # disable pagination\n\n    serializer_class = EventSerializer\n    queryset = Event.objects.exclude(\n        Q(start__isnull=True) | Q(url__isnull=True)\n    ).order_by('-start')\n", "path": "api/views.py"}]}