Monday, February 2, 2015

ListView and Deleteview

Hello everybody,

I'm working in a website using django. I would like that users could select and delete data introduced for them. I've found some information on the web and it seems that the ListView and DeleteView is what I need. However, when I try to do a ListView, it doesn't work and I don't know why.

Here my code:

models.py:

class Pozo(models.Model):
    # gid_pozo = models.IntegerField(primary_key=True)
    # gid_colector = models.ForeignKey(Colector)
    codpozo = models.CharField(max_length=20)
    coorx = models.DecimalField(max_digits=13, decimal_places=5)
    coory = models.DecimalField(max_digits=13, decimal_places=5)
    tipo = models.CharField(max_length=20)
    cotatrapa = models.DecimalField(max_digits=6, decimal_places=2, default=None, blank=True, null=True)
    profundidad = models.DecimalField(max_digits=6, decimal_places=2, default=None, blank=True, null=True)
    cotafondo = models.DecimalField(max_digits=6, decimal_places=2, default=None, blank=True, null=True)
    material = models.CharField(max_length=20)
    materialpates = models.CharField(max_length=20)
    diametro = models.DecimalField(max_digits=20, decimal_places=2, default=None, blank=True, null=True)
    largotrapa = models.DecimalField(max_digits=20, decimal_places=2, default=None, blank=True, null=True)
    seccionmayor = models.DecimalField(max_digits=5, decimal_places=0, default=None, blank=True, null=True)
    seccionmenor = models.DecimalField(max_digits=5, decimal_places=0, default=None, blank=True, null=True)
    numacometidas = models.DecimalField(max_digits=2, decimal_places=0, default=None, blank=True, null=True)
    origen = models.CharField(max_length=20)
    observaciones = models.CharField(max_length=255) 
    geom = models.PointField(srid=25830)
    objects = models.GeoManager()

views.py:

def PozoList(ListView):  
    model = Pozo
    template_name = 'cuencas/edicioncuenca.html'

template:

<select>
              {% for pozo in object_list %}
                  <option>{{ pozo.codpozo }}</option>
              {% endfor %}
</select>

And the result is a field without options. Does anybody know what I'm doing wrong?
Thank you very much!

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/9492aae7-31bf-4283-9399-5c50f04dfcfa%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment