Django - queryset in a charfield form
<p>I need help please, I'm trying to showing a <code>select</code> in my template from a <code>queryset()</code> but it's not working properly. </p>

<p>Here's what I got:</p>

<pre><code>from __future__ import unicode_literals

from django.db import models

# Create your models here.
from django import forms
from activos.models import activos
from activos.forms import activosForm
# Create your models here.
class grupos(models.Model):
    nombre_grupo = models.CharField(max_length=100)
    frecuencia = models.CharField(max_length=100)
    offset = models.CharField(max_length=100)
    activos_class = activos()
    activos_query = activos.objects.all()
    res =str(activos_query)
    PORT_CHOICES = (res,res),
    nombre_puerto = models.CharField(max_length=100,choices=PORT_CHOICES)

    def __unicode__(self):
        return self.nombre_grupo

    def __str__(self):
        return self.nombre_grupo
</code></pre>

<p>as you can see I'm calling <code>usuario</code> from <code>activos()</code> which is in another app from my project, I want to show that result in a <code>select</code> in my template
but when doing so I got something like this:</p>

<pre><code>-------------
&lt;QuerySet[&lt;activos:alvaro&gt;, &lt;activos:david&gt;,&lt;activos:daniel&gt;]&gt;
</code></pre>

<p>I want something like this:</p>

<pre><code>-----
alvaro
david
daniel
</code></pre>

<p>I tried to avoid that editing this line <code>res =str(activos_query[0])</code> but if I delete every user from my database I ll get <code>index error</code></p>

<p>Is there an efficient way to do that?</p>

<p>Django version: 1.10.4</p>

<p><strong>EDIT</strong></p>

<p><strong>grupos views.py</strong></p>

<pre><code>from django.shortcuts import render
from django.conf import settings
from django.core.mail import send_mail
from .forms import gruposModelForm
from .models import grupos
from activos.models import activos


def grupos_test(request):
    titulo = "hola"
    if request.user.is_authenticated():
        titulo = "bienvenido %s" %(request.user)
    form = gruposModelForm(request.POST or None)
    queryset = grupos.objects.all()
    # query_delete = queryset.delete()
    context = {
    "titulo": titulo,
    "form": form,
    "queryset": queryset,
    "res": res,
    }
    if form.is_valid():
        instance = form.save(commit=False)
        nombre_grupo = form.cleaned_data.get("nombre_grupo")
        frecuencia = form.cleaned_data.get("frecuencia")
        if not instance.nombre_grupo:
            instance.nombre_grupo = "PERSONA"
        instance.save()
        context = {
            "titulo": "Gracias %s" %(nombre_grupo)
        }
        if not nombre_grupo:
            context = {
                "titulo": "Gracias %s!" %("desconocido"),
                "form": form,
            }

        # form_data = form.cleaned_data
        # abc =  form_data.get("email")
        # abc2 = form_data.get("nombre")
        # obj = Registrado.objects.create(email=abc,nombre=abc2)
    # context = {
    #   "titulo": titulo,
    #   "form": form,
    # }
    return render(request, "forms5.html", context)
</code></pre>

<p><strong>html</strong></p>

<pre><code>{{ titulo }}
&lt;hr/&gt;
&lt;br/&gt;
&lt;form method="POST" action=""&gt;{% csrf_token %}
{{ form.as_p }}
&lt;input type="submit" value="Registrame" /&gt;
&lt;/form&gt;

&lt;p&gt;EXAMPLE&lt;/p&gt;
{% for g in queryset %}
  &lt;select&gt;{{ g.usuario }}&lt;/select&gt;
{% endfor %}
</code></pre>