prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  500 error on FMV Detail View page
  I noticed this bug when trying to use the FMV module on Danesfield. I tested it on a fresh RGD instance and it still occured.
  
  To reproduce -
  - Run the `rgd_fmv_wasabi` management command to populate your DB with FMV data
  - Attempt to navigate to `http://localhost:8000/rgd_fmv/<:id>/` and it will return a 500 error with the error `string indices must be integers
  `.
  500 error on `/rgd_fmv/{spatial_id}` endpoint
  I noticed this bug when trying to use the FMV module on Danesfield. I tested it on a fresh RGD instance and it still occurred.
  
  To reproduce -
  
  - Run the `rgd_fmv_wasabi` management command to populate your DB with FMV data
  - Hit the `/rgd_fmv/{spatial_id}` API endpoint and a 500 will be returned with an error ```AttributeError at /api/rgd_fmv/1
  Got AttributeError when attempting to get a value for field `file` on serializer `FMVSerializer`.
  The serializer field might be named incorrectly and not match any attribute or key on the `FMVMeta` instance.
  Original exception text was: 'FMVMeta' object has no attribute 'file'.```
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `django-rgd-fmv/rgd_fmv/rest/viewsets.py`
  Content:
  ```
  1 from rest_framework.decorators import action
  2 from rgd.rest.base import ModelViewSet
  3 from rgd_fmv import models, serializers
  4 
  5 
  6 class FMVViewSet(ModelViewSet):
  7     queryset = models.FMVMeta.objects.all()
  8 
  9     def get_serializer_class(self):
  10         if self.action in ['get', 'list']:
  11             return serializers.FMVMetaSerializer
  12         return serializers.FMVSerializer
  13 
  14     @action(detail=True, serializer_class=serializers.FMVMetaDataSerializer)
  15     def data(self, request, *args, **kwargs):
  16         return self.retrieve(request, *args, **kwargs)
  17
  ```
  
  Path: `django-rgd-fmv/rgd_fmv/views.py`
  Content:
  ```
  1 import json
  2 
  3 from rgd.views import SpatialDetailView
  4 
  5 from . import models
  6 
  7 
  8 class FMVMetaDetailView(SpatialDetailView):
  9     model = models.FMVMeta
  10 
  11     def get_context_data(self, *args, **kwargs):
  12         context = super().get_context_data(*args, **kwargs)
  13         context['frame_rate'] = json.dumps(self.object.fmv_file.frame_rate)
  14         extents = context['extents']
  15         if self.object.ground_union is not None:
  16             # All or none of these will be set, only check one
  17             extents['collect'] = self.object.ground_union.json
  18             extents['ground_frames'] = self.object.ground_frames.json
  19             extents['frame_numbers'] = self.object._blob_to_array(self.object.frame_numbers)
  20         return context
  21
  ```
  
  Path: `django-rgd-fmv/rgd_fmv/urls.py`
  Content:
  ```
  1 from django.urls import path
  2 from rest_framework.routers import SimpleRouter
  3 from rgd_fmv import models, views
  4 from rgd_fmv.rest import viewsets
  5 
  6 router = SimpleRouter(trailing_slash=False)
  7 router.register(r'api/rgd_fmv', viewsets.FMVViewSet)
  8 
  9 urlpatterns = [
  10     # Pages
  11     path(
  12         'rgd_fmv/<int:pk>/',
  13         views.FMVMetaDetailView.as_view(),
  14         name=models.FMVMeta.detail_view_name,
  15     ),
  16 ] + router.urls
  17
  ```
  --- 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/django-rgd-fmv/rgd_fmv/rest/viewsets.py b/django-rgd-fmv/rgd_fmv/rest/viewsets.py
  --- a/django-rgd-fmv/rgd_fmv/rest/viewsets.py
  +++ b/django-rgd-fmv/rgd_fmv/rest/viewsets.py
  @@ -1,16 +1,17 @@
   from rest_framework.decorators import action
  -from rgd.rest.base import ModelViewSet
  +from rgd.rest.base import ModelViewSet, ReadOnlyModelViewSet
   from rgd_fmv import models, serializers
   
   
  -class FMVViewSet(ModelViewSet):
  +class FMVMetaViewSet(ReadOnlyModelViewSet):
       queryset = models.FMVMeta.objects.all()
  -
  -    def get_serializer_class(self):
  -        if self.action in ['get', 'list']:
  -            return serializers.FMVMetaSerializer
  -        return serializers.FMVSerializer
  +    serializer_class = serializers.FMVMetaSerializer
   
       @action(detail=True, serializer_class=serializers.FMVMetaDataSerializer)
       def data(self, request, *args, **kwargs):
           return self.retrieve(request, *args, **kwargs)
  +
  +
  +class FMVViewSet(ModelViewSet):
  +    queryset = models.FMV.objects.all()
  +    serializer_class = serializers.FMVSerializer
  diff --git a/django-rgd-fmv/rgd_fmv/urls.py b/django-rgd-fmv/rgd_fmv/urls.py
  --- a/django-rgd-fmv/rgd_fmv/urls.py
  +++ b/django-rgd-fmv/rgd_fmv/urls.py
  @@ -4,7 +4,8 @@
   from rgd_fmv.rest import viewsets
   
   router = SimpleRouter(trailing_slash=False)
  -router.register(r'api/rgd_fmv', viewsets.FMVViewSet)
  +router.register(r'api/rgd_fmv', viewsets.FMVMetaViewSet, basename='fmv-meta')
  +router.register(r'api/rgd_fmv/model', viewsets.FMVViewSet, basename='fmv')
   
   urlpatterns = [
       # Pages
  diff --git a/django-rgd-fmv/rgd_fmv/views.py b/django-rgd-fmv/rgd_fmv/views.py
  --- a/django-rgd-fmv/rgd_fmv/views.py
  +++ b/django-rgd-fmv/rgd_fmv/views.py
  @@ -11,10 +11,11 @@
       def get_context_data(self, *args, **kwargs):
           context = super().get_context_data(*args, **kwargs)
           context['frame_rate'] = json.dumps(self.object.fmv_file.frame_rate)
  -        extents = context['extents']
  +        extents = json.loads(context['extents'])
           if self.object.ground_union is not None:
               # All or none of these will be set, only check one
               extents['collect'] = self.object.ground_union.json
               extents['ground_frames'] = self.object.ground_frames.json
               extents['frame_numbers'] = self.object._blob_to_array(self.object.frame_numbers)
  +        context['extents'] = json.dumps(extents)
           return context
  
verification_info: {"golden_diff": "diff --git a/django-rgd-fmv/rgd_fmv/rest/viewsets.py b/django-rgd-fmv/rgd_fmv/rest/viewsets.py\n--- a/django-rgd-fmv/rgd_fmv/rest/viewsets.py\n+++ b/django-rgd-fmv/rgd_fmv/rest/viewsets.py\n@@ -1,16 +1,17 @@\n from rest_framework.decorators import action\n-from rgd.rest.base import ModelViewSet\n+from rgd.rest.base import ModelViewSet, ReadOnlyModelViewSet\n from rgd_fmv import models, serializers\n \n \n-class FMVViewSet(ModelViewSet):\n+class FMVMetaViewSet(ReadOnlyModelViewSet):\n     queryset = models.FMVMeta.objects.all()\n-\n-    def get_serializer_class(self):\n-        if self.action in ['get', 'list']:\n-            return serializers.FMVMetaSerializer\n-        return serializers.FMVSerializer\n+    serializer_class = serializers.FMVMetaSerializer\n \n     @action(detail=True, serializer_class=serializers.FMVMetaDataSerializer)\n     def data(self, request, *args, **kwargs):\n         return self.retrieve(request, *args, **kwargs)\n+\n+\n+class FMVViewSet(ModelViewSet):\n+    queryset = models.FMV.objects.all()\n+    serializer_class = serializers.FMVSerializer\ndiff --git a/django-rgd-fmv/rgd_fmv/urls.py b/django-rgd-fmv/rgd_fmv/urls.py\n--- a/django-rgd-fmv/rgd_fmv/urls.py\n+++ b/django-rgd-fmv/rgd_fmv/urls.py\n@@ -4,7 +4,8 @@\n from rgd_fmv.rest import viewsets\n \n router = SimpleRouter(trailing_slash=False)\n-router.register(r'api/rgd_fmv', viewsets.FMVViewSet)\n+router.register(r'api/rgd_fmv', viewsets.FMVMetaViewSet, basename='fmv-meta')\n+router.register(r'api/rgd_fmv/model', viewsets.FMVViewSet, basename='fmv')\n \n urlpatterns = [\n     # Pages\ndiff --git a/django-rgd-fmv/rgd_fmv/views.py b/django-rgd-fmv/rgd_fmv/views.py\n--- a/django-rgd-fmv/rgd_fmv/views.py\n+++ b/django-rgd-fmv/rgd_fmv/views.py\n@@ -11,10 +11,11 @@\n     def get_context_data(self, *args, **kwargs):\n         context = super().get_context_data(*args, **kwargs)\n         context['frame_rate'] = json.dumps(self.object.fmv_file.frame_rate)\n-        extents = context['extents']\n+        extents = json.loads(context['extents'])\n         if self.object.ground_union is not None:\n             # All or none of these will be set, only check one\n             extents['collect'] = self.object.ground_union.json\n             extents['ground_frames'] = self.object.ground_frames.json\n             extents['frame_numbers'] = self.object._blob_to_array(self.object.frame_numbers)\n+        context['extents'] = json.dumps(extents)\n         return context\n", "issue": "500 error on FMV Detail View page\nI noticed this bug when trying to use the FMV module on Danesfield. I tested it on a fresh RGD instance and it still occured.\r\n\r\nTo reproduce -\r\n- Run the `rgd_fmv_wasabi` management command to populate your DB with FMV data\r\n- Attempt to navigate to `http://localhost:8000/rgd_fmv/<:id>/` and it will return a 500 error with the error `string indices must be integers\r\n`.\n500 error on `/rgd_fmv/{spatial_id}` endpoint\nI noticed this bug when trying to use the FMV module on Danesfield. I tested it on a fresh RGD instance and it still occurred.\r\n\r\nTo reproduce -\r\n\r\n- Run the `rgd_fmv_wasabi` management command to populate your DB with FMV data\r\n- Hit the `/rgd_fmv/{spatial_id}` API endpoint and a 500 will be returned with an error ```AttributeError at /api/rgd_fmv/1\r\nGot AttributeError when attempting to get a value for field `file` on serializer `FMVSerializer`.\r\nThe serializer field might be named incorrectly and not match any attribute or key on the `FMVMeta` instance.\r\nOriginal exception text was: 'FMVMeta' object has no attribute 'file'.```\n", "before_files": [{"content": "from rest_framework.decorators import action\nfrom rgd.rest.base import ModelViewSet\nfrom rgd_fmv import models, serializers\n\n\nclass FMVViewSet(ModelViewSet):\n    queryset = models.FMVMeta.objects.all()\n\n    def get_serializer_class(self):\n        if self.action in ['get', 'list']:\n            return serializers.FMVMetaSerializer\n        return serializers.FMVSerializer\n\n    @action(detail=True, serializer_class=serializers.FMVMetaDataSerializer)\n    def data(self, request, *args, **kwargs):\n        return self.retrieve(request, *args, **kwargs)\n", "path": "django-rgd-fmv/rgd_fmv/rest/viewsets.py"}, {"content": "import json\n\nfrom rgd.views import SpatialDetailView\n\nfrom . import models\n\n\nclass FMVMetaDetailView(SpatialDetailView):\n    model = models.FMVMeta\n\n    def get_context_data(self, *args, **kwargs):\n        context = super().get_context_data(*args, **kwargs)\n        context['frame_rate'] = json.dumps(self.object.fmv_file.frame_rate)\n        extents = context['extents']\n        if self.object.ground_union is not None:\n            # All or none of these will be set, only check one\n            extents['collect'] = self.object.ground_union.json\n            extents['ground_frames'] = self.object.ground_frames.json\n            extents['frame_numbers'] = self.object._blob_to_array(self.object.frame_numbers)\n        return context\n", "path": "django-rgd-fmv/rgd_fmv/views.py"}, {"content": "from django.urls import path\nfrom rest_framework.routers import SimpleRouter\nfrom rgd_fmv import models, views\nfrom rgd_fmv.rest import viewsets\n\nrouter = SimpleRouter(trailing_slash=False)\nrouter.register(r'api/rgd_fmv', viewsets.FMVViewSet)\n\nurlpatterns = [\n    # Pages\n    path(\n        'rgd_fmv/<int:pk>/',\n        views.FMVMetaDetailView.as_view(),\n        name=models.FMVMeta.detail_view_name,\n    ),\n] + router.urls\n", "path": "django-rgd-fmv/rgd_fmv/urls.py"}], "after_files": [{"content": "from rest_framework.decorators import action\nfrom rgd.rest.base import ModelViewSet, ReadOnlyModelViewSet\nfrom rgd_fmv import models, serializers\n\n\nclass FMVMetaViewSet(ReadOnlyModelViewSet):\n    queryset = models.FMVMeta.objects.all()\n    serializer_class = serializers.FMVMetaSerializer\n\n    @action(detail=True, serializer_class=serializers.FMVMetaDataSerializer)\n    def data(self, request, *args, **kwargs):\n        return self.retrieve(request, *args, **kwargs)\n\n\nclass FMVViewSet(ModelViewSet):\n    queryset = models.FMV.objects.all()\n    serializer_class = serializers.FMVSerializer\n", "path": "django-rgd-fmv/rgd_fmv/rest/viewsets.py"}, {"content": "import json\n\nfrom rgd.views import SpatialDetailView\n\nfrom . import models\n\n\nclass FMVMetaDetailView(SpatialDetailView):\n    model = models.FMVMeta\n\n    def get_context_data(self, *args, **kwargs):\n        context = super().get_context_data(*args, **kwargs)\n        context['frame_rate'] = json.dumps(self.object.fmv_file.frame_rate)\n        extents = json.loads(context['extents'])\n        if self.object.ground_union is not None:\n            # All or none of these will be set, only check one\n            extents['collect'] = self.object.ground_union.json\n            extents['ground_frames'] = self.object.ground_frames.json\n            extents['frame_numbers'] = self.object._blob_to_array(self.object.frame_numbers)\n        context['extents'] = json.dumps(extents)\n        return context\n", "path": "django-rgd-fmv/rgd_fmv/views.py"}, {"content": "from django.urls import path\nfrom rest_framework.routers import SimpleRouter\nfrom rgd_fmv import models, views\nfrom rgd_fmv.rest import viewsets\n\nrouter = SimpleRouter(trailing_slash=False)\nrouter.register(r'api/rgd_fmv', viewsets.FMVMetaViewSet, basename='fmv-meta')\nrouter.register(r'api/rgd_fmv/model', viewsets.FMVViewSet, basename='fmv')\n\nurlpatterns = [\n    # Pages\n    path(\n        'rgd_fmv/<int:pk>/',\n        views.FMVMetaDetailView.as_view(),\n        name=models.FMVMeta.detail_view_name,\n    ),\n] + router.urls\n", "path": "django-rgd-fmv/rgd_fmv/urls.py"}]}