This code throws me the error:
matching query does not exist
Apparently the filter I have designed does not capture the id of the Orders.
Code:
models.py:
class Pedido(models.Model):
especialidad = models.ForeignKey('Especialidad')
articulo = models.ForeignKey('Articulo')
fecha_entrega = models.DateTimeField(auto_now_add=False)
fecha_pedido = models.DateTimeField(auto_now_add=True,null=True, blank=True)
cantidad = models.IntegerField(blank=True)
pendiente = models.CharField(max_length=999, null=True, blank=True)
estado = models.CharField(max_length=20, blank=True, default='pendiente')
views.py
def ArticuloListView(request, id_especialidad):
user = request.user
if user.is_superuser:
pedido = Pedido.objects.get(id=id_especialidad) #filtro de error
else:
pedido = Pedido.objects.filter(especialidad__encargado__usuario=user.id)
template = 'index2.html'
return render_to_response(template,locals(), Context)
Here the url: (this if you capture the id selected)
url(r'^lista_esp/(?P<id_especialidad>\d+)/$', ArticuloListView, name="listar_esp"),
I do not know how to create an adequate filter for what is required. Any help please? Thanks in advance.