Q:

Request 'GET' - Django CRUD conditional

I'm trying to make a query on my DB, in Django, but so far I'm not getting any results, I'm kind of confused on this one.
Say proyecto is a kind of document I need to query, then I have this on models:
class Proyecto(models.Model):
    id_proyecto = models.IntegerField(primary_key=True) #integer NOT NULL, CLAVE PRIMARIA
    nombre_proyecto = models.TextField(null=True) #text,
    existente = models.BooleanField()

Here, existente is a checkmark I have on my template, so, if this checkmark is active, then bring whatever document are you specifying into nombre_proyecto charfield.
forms.py:
class ProyectoForm(forms.Form):
    nombre_proyecto = forms.CharField(widget=forms.TextInput())
    existente = forms.BooleanField(required=False)

    def clean(self):
        return self.cleaned_data

Then, views.py:
def proyecto_view(request):
alerta=""
#existente = request.GET['existente']
#if existente is not None and existente != '':
if request.method == "POST":
    form = ProyectoForm(request.POST)
    if form.is_valid():
        name =form.cleaned_data['nombre_proyecto'] #hay que verificar si el proyecto ya existe
        if Proyecto.objects.count() > 0:
            alerta="ya existe el proyecto"
            formProy = 1
            ctx ={'alerta':alerta, 'formProy':formProy}
            return render_to_response('scppp/inicial.html', ctx, context_instance=RequestContext(request))
        else:
            if Proyecto.objects.count() == 0:
                id_proyecto=1
            else:
                id_proyecto=Proyecto.objects.all().aggregate(Max('id_proyecto'))['id_proyecto__max']+1
            nombre_proyecto = name

    else:
        if Proyecto.objects.count() < 0:
            alerta = "Introduzca un nombre de proyecto"
            formProy = 1
        else:
            alerta = "data erronea"
            formProy = 1
            ctx = {'alerta':alerta, 'formProy':formProy}
            return render_to_response('scppp/inicial.html', ctx, context_instance=RequestContext(request))
if request.method == "GET" and 'existente' in request.GET: //This is the method
    existente = request.GET['existente']
    if existente is not None and existente != '':
        Proyecto.objects.filter(nombre_proyecto=name)
        return render_to_response('scppp/pozo.html', ctx, context_instance=RequestContext(request))

On my template, this is how I have the checkmark existente:
<tr><td>
                    <span class="Sub-Titulo-Aplicacion">Proyecto: </span>
                    <input class="check-style" type="checkbox" name="tipo" value="checkbox" >Nuevo</input>
                  </td></tr>
                  <tr><td>
                    <input class="check-style" type="checkbox" name="existente" value="existente" >Existente</input>
                  </td></tr>

The checkmark "works" in an HTML point of view, but it's actually doing nothing... I don't know if I should declare something on my template or not, there are plenty of ways and I feel confused.
Any ideas?
Many thanks in advance!

A:

You have some obvious bug in your code:
if Proyecto.objects.count() < 0:

count means an act of determining the total number of something. and total number of something can not be less than zero. 
So your code is logically wrong. this bug also affect these lines:
    if Proyecto.objects.count() > 0:
        alerta="ya existe el proyecto"
        formProy = 1
        ctx ={'alerta':alerta, 'formProy':formProy}
        return render_to_response('scppp/inicial.html', ctx, context_instance=RequestContext(request))
    else:
        if Proyecto.objects.count() == 0:
            id_proyecto=1
        else:
            id_proyecto=Proyecto.objects.all().aggregate(Max('id_proyecto'))['id_proyecto__max']+1
        nombre_proyecto = name

Executation never reachs to else statement.
Also in your ** GET request ** processing in views there is another mistake.
if existente is not None and existente != '':
    Proyecto.objects.filter(nombre_proyecto=name)
    return render_to_response('scppp/pozo.html', ctx, context_instance=RequestContext(request))

you didn't use selected Proyecto instance from database. You should pass them to your template. Also you didn't declared ctx in this scope. (You just did it in POST request handling and a request can not be both of POST and GET).
if existente is not None and existente != '':
    projects = Proyecto.objects.filter(nombre_proyecto=name)
    ctx = {"projects" : projects}
    return render_to_response('scppp/pozo.html', ctx, context_instance=RequestContext(request))

and also in your scppp/pozo.html you must have something like this to show them and use projects:
<table>
    {% for project in projects %}
    <tr>
        <td>{{project.id_proyecto}}</td>
        <td>{{project.nombre_proyecto}}</td>
   </tr>
   {% endfor %}
</table>

