prompt: We are currently solving the following issue within our repository. Here is the issue text:
  --- BEGIN ISSUE ---
  Audiências Públicas sem possibilidade de Edição
  Ao criar uma Audiência Pública e salva-la, não aparecem os metadados da matéria legislativa inseridas no preenchimento. 
  Ao clicar em Editar, só  aparece o título da audiência criada.
  grato
  
  --- END ISSUE ---
  
  Below are some code segments, each from a relevant file. One or more of these files may contain bugs.
  --- BEGIN FILES ---
  Path: `sapl/audiencia/views.py`
  Content:
  ```
  1 from django.http import HttpResponse
  2 from django.views.decorators.clickjacking import xframe_options_exempt
  3 from django.views.generic import UpdateView
  4 from sapl.crud.base import RP_DETAIL, RP_LIST, Crud
  5 
  6 from .forms import AudienciaForm
  7 from .models import AudienciaPublica
  8 
  9 
  10 def index(request):
  11     return HttpResponse("Audiência  Pública")
  12 
  13 
  14 class AudienciaCrud(Crud):
  15     model = AudienciaPublica
  16     public = [RP_LIST, RP_DETAIL, ]
  17 
  18     class BaseMixin(Crud.BaseMixin):
  19         list_field_names = ['numero', 'nome', 'tipo', 'materia',
  20                             'data']
  21         ordering = 'nome', 'numero', 'tipo', 'data'
  22 
  23     class ListView(Crud.ListView):
  24         paginate_by = 10
  25 
  26     class CreateView(Crud.CreateView):
  27         form_class = AudienciaForm
  28 
  29         def form_valid(self, form):
  30             return super(Crud.CreateView, self).form_valid(form)
  31 
  32     class UpdateView(Crud.UpdateView):
  33         form_class = AudienciaForm
  34 
  35         def get_initial(self):
  36             initial = super(UpdateView, self).get_initial()
  37             initial['tipo_materia'] = self.object.materia.tipo.id
  38             initial['numero_materia'] = self.object.materia.numero
  39             initial['ano_materia'] = self.object.materia.ano
  40             return initial
  41      
  42     class DeleteView(Crud.DeleteView):
  43         pass
  44 
  45     class DetailView(Crud.DetailView):
  46 
  47         layout_key = 'AudienciaPublicaDetail'
  48 
  49         @xframe_options_exempt
  50         def get(self, request, *args, **kwargs):
  51             return super().get(request, *args, **kwargs)
  52 
  53
  ```
  --- 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/sapl/audiencia/views.py b/sapl/audiencia/views.py
  --- a/sapl/audiencia/views.py
  +++ b/sapl/audiencia/views.py
  @@ -34,9 +34,10 @@
   
           def get_initial(self):
               initial = super(UpdateView, self).get_initial()
  -            initial['tipo_materia'] = self.object.materia.tipo.id
  -            initial['numero_materia'] = self.object.materia.numero
  -            initial['ano_materia'] = self.object.materia.ano
  +            if self.object.materia:
  +                initial['tipo_materia'] = self.object.materia.tipo.id
  +                initial['numero_materia'] = self.object.materia.numero
  +                initial['ano_materia'] = self.object.materia.ano
               return initial
        
       class DeleteView(Crud.DeleteView):
  
verification_info: {"golden_diff": "diff --git a/sapl/audiencia/views.py b/sapl/audiencia/views.py\n--- a/sapl/audiencia/views.py\n+++ b/sapl/audiencia/views.py\n@@ -34,9 +34,10 @@\n \n         def get_initial(self):\n             initial = super(UpdateView, self).get_initial()\n-            initial['tipo_materia'] = self.object.materia.tipo.id\n-            initial['numero_materia'] = self.object.materia.numero\n-            initial['ano_materia'] = self.object.materia.ano\n+            if self.object.materia:\n+                initial['tipo_materia'] = self.object.materia.tipo.id\n+                initial['numero_materia'] = self.object.materia.numero\n+                initial['ano_materia'] = self.object.materia.ano\n             return initial\n      \n     class DeleteView(Crud.DeleteView):\n", "issue": "Audi\u00eancias P\u00fablicas sem possibilidade de Edi\u00e7\u00e3o\nAo criar uma Audi\u00eancia P\u00fablica e salva-la, n\u00e3o aparecem os metadados da mat\u00e9ria legislativa inseridas no preenchimento. \r\nAo clicar em Editar, s\u00f3  aparece o t\u00edtulo da audi\u00eancia criada.\r\ngrato\n", "before_files": [{"content": "from django.http import HttpResponse\nfrom django.views.decorators.clickjacking import xframe_options_exempt\nfrom django.views.generic import UpdateView\nfrom sapl.crud.base import RP_DETAIL, RP_LIST, Crud\n\nfrom .forms import AudienciaForm\nfrom .models import AudienciaPublica\n\n\ndef index(request):\n    return HttpResponse(\"Audi\u00eancia  P\u00fablica\")\n\n\nclass AudienciaCrud(Crud):\n    model = AudienciaPublica\n    public = [RP_LIST, RP_DETAIL, ]\n\n    class BaseMixin(Crud.BaseMixin):\n        list_field_names = ['numero', 'nome', 'tipo', 'materia',\n                            'data']\n        ordering = 'nome', 'numero', 'tipo', 'data'\n\n    class ListView(Crud.ListView):\n        paginate_by = 10\n\n    class CreateView(Crud.CreateView):\n        form_class = AudienciaForm\n\n        def form_valid(self, form):\n            return super(Crud.CreateView, self).form_valid(form)\n\n    class UpdateView(Crud.UpdateView):\n        form_class = AudienciaForm\n\n        def get_initial(self):\n            initial = super(UpdateView, self).get_initial()\n            initial['tipo_materia'] = self.object.materia.tipo.id\n            initial['numero_materia'] = self.object.materia.numero\n            initial['ano_materia'] = self.object.materia.ano\n            return initial\n     \n    class DeleteView(Crud.DeleteView):\n        pass\n\n    class DetailView(Crud.DetailView):\n\n        layout_key = 'AudienciaPublicaDetail'\n\n        @xframe_options_exempt\n        def get(self, request, *args, **kwargs):\n            return super().get(request, *args, **kwargs)\n\n    ", "path": "sapl/audiencia/views.py"}], "after_files": [{"content": "from django.http import HttpResponse\nfrom django.views.decorators.clickjacking import xframe_options_exempt\nfrom django.views.generic import UpdateView\nfrom sapl.crud.base import RP_DETAIL, RP_LIST, Crud\n\nfrom .forms import AudienciaForm\nfrom .models import AudienciaPublica\n\n\ndef index(request):\n    return HttpResponse(\"Audi\u00eancia  P\u00fablica\")\n\n\nclass AudienciaCrud(Crud):\n    model = AudienciaPublica\n    public = [RP_LIST, RP_DETAIL, ]\n\n    class BaseMixin(Crud.BaseMixin):\n        list_field_names = ['numero', 'nome', 'tipo', 'materia',\n                            'data']\n        ordering = 'nome', 'numero', 'tipo', 'data'\n\n    class ListView(Crud.ListView):\n        paginate_by = 10\n\n    class CreateView(Crud.CreateView):\n        form_class = AudienciaForm\n\n        def form_valid(self, form):\n            return super(Crud.CreateView, self).form_valid(form)\n\n    class UpdateView(Crud.UpdateView):\n        form_class = AudienciaForm\n\n        def get_initial(self):\n            initial = super(UpdateView, self).get_initial()\n            if self.object.materia:\n                initial['tipo_materia'] = self.object.materia.tipo.id\n                initial['numero_materia'] = self.object.materia.numero\n                initial['ano_materia'] = self.object.materia.ano\n            return initial\n     \n    class DeleteView(Crud.DeleteView):\n        pass\n\n    class DetailView(Crud.DetailView):\n\n        layout_key = 'AudienciaPublicaDetail'\n\n        @xframe_options_exempt\n        def get(self, request, *args, **kwargs):\n            return super().get(request, *args, **kwargs)\n\n    ", "path": "sapl/audiencia/views.py"}]}