I have a problem I need to send a list to my database that I get by checkbox, but the problem is that I get local variable 'medicinas' referenced before assignment error, I don't know what is wrong, this is my view. 

View.py

```
def solicitud_laboratorio(request):
    if request.method == 'POST':
        datos = Solicitud_lab(request.POST)
        if datos.is_valid():
            print 'inside if Datos'
            datos.save()
            medicinas = []
        for i in range(len(request.POST.getlist('examen'))):
            print i
            data = {
            'nombre_examen': request.POST.getlist('examen')[i],
            'credencial': request.POST['laboratorio_credencial']

        }
        print data
        medicina = examenlab_form(data)

        if medicina.is_valid():
            medicina.save()
            medicinas.append(medicina)
            messages.success(request, 'Alta Exitosa!')
        return HttpResponseRedirect('')
    else:
        messages.success(request, 'Se presento un error al dar de alta')
else:
    medicinas = [examenlab_form()]
    datos = Solicitud_lab()
return render_to_response('sol_laboratorio.html', {'medicinas': medicinas, 'datos': datos},
                          context_instance=RequestContext(request))

```

sol\_laboratorio-html

```
 <form id='formulario' method='post' name="example form" enctype='multipart/form-data' action=''>    {% csrf_token %}
  <table style="width:95%;" align="center" width="100%" cellspacing="0" cellpadding="6" border="0">
    <div style="text-align:center; font-style: oblique; color: red">
        {% if messages %}
            <ul class="messages">
                {% for message in messages %}
                        <li{% if message.tags %} class="{{ message.tags }}"{% endif %}><b>     {{ message }}</b></li>
                {% endfor %}
            </ul>
        {% endif %}
    </div>
    <tr>
        <th align="center" bgcolor="#85D5EF" colspan="7">Solicitud Estudios de Laboratorio</th>
    </tr>
    <tr>
        <br>
        <td><label>Fecha:</label>
        <td>
            <output><b>{% now "D d M Y" %}</b></output>
        </td>
        <td>{{ formulario.medico_solicita_2.errors }} <label>Nombre del Medico Que Solicita: </label></td>
        <td>{{ formulario.medico_solicita_2 }} </td>
        <td><label>Credencial:</label></td>
        <td><input name="laboratorio_credencial" class="forminput"
                   id={{ formulario.credencial_consultainicial }}</input></td>
   </tr>
    <tr>
        <td><label>Nombre:</label></td>
        <td><input name="nombre_pac_3" id="nombre_pac_3"></input></td>
        <td><label>Apellido:</label></td>
        <td><input name="apellido_pac" id="apellido_pac"></input></td>
        <td><label>Fecha De Nacimiento:</label></td>
        <td><input name="fecha_nacimiento_5" id="fecha_nacimiento_5"></input></td>
    </tr>
    <tr>
    </tr>
    <tr>
        <td><label>Edad:</label></td>
        <td><input name="edad_miembro9" id="edad_miembro9"></input></td>
        <td><label>Sexo:</label></td>
        <td><input name="sexo_4" id="sexo_4"></input></td>
    </tr>
</table>
<table style="width:95%;" align="center" width="95%" cellspacing="0" cellpadding="5" border="0">
    <tr>
        <td align="center"><label>Impresion Diagnostica 1(ICD-10): </label>
            <br/><input name="impresion_diagnostica" id="impresion_diagnostica"></input></td>

        <td align="center"><label>Impresion Diagnostica 2(ICD-10): </label>
            <br/><input name="impresion_diagnostica2" id="impresion_diagnostica2"></input></td>

        <td align="center"><label>Impresion Diagnostica 3(ICD-10): </label>
            <br/><input name="impresion_diagnostica3" id="impresion_diagnostica3"></input></td>

        <td align="center"><label>Impresion Diagnostica 4(ICD-10): </label>
            <br/><input name="impresion_diagnostica4" id="impresion_diagnostica4"></input></td>
    </tr>
</table>

```

error

```
UnboundLocalError at /laboratorio/
local variable 'medicinas' referenced before assignment
Request Method: POST
Request URL:    http://localhost:8000/laboratorio/
Django Version: 1.4.3
Exception Type: UnboundLocalError
Exception Value:    
local variable 'medicinas' referenced before assignment
Exception Location: C:\proyectomediexcel\expmedico\views.py in solicitud_laboratorio,    line 265
Python Executable:  c:\Python27\python.exe
Python Version: 2.7.5
Python Path:    
['C:\\proyectomediexcel',
'c:\\Python27\\lib\\site-packages\\setuptools-1.1.4-py2.7.egg',
'c:\\Python27\\lib\\site-packages\\pip-1.1-py2.7.egg',
'c:\\Python27\\lib\\site-packages\\django_pagination-1.0.7-py2.7.egg',
'C:\\Windows\\system32\\python27.zip',
'c:\\Python27\\DLLs',
'c:\\Python27\\lib',
'c:\\Python27\\lib\\plat-win',
'c:\\Python27\\lib\\lib-tk',
'c:\\Python27',
'c:\\Python27\\lib\\site-packages']
Server time:    lun, 30 Sep 2013 12:04:28 -0700

```