After debugging for a while, I found out what happened, but I don't know how to fix it.
- I have a urlConf named '
ver_caja ' that takes the id of a caja object as an argument and then calls the generic object_detail . - The request rule is correct: correctly return all caja objects.
- In the template, I have a call:
{% ver_caja caja.id %} - The
caja object is correctly accepted by the template. - I am using MySQL.
The problem is that caja.id has a value of "1L" instead of "1" .
This 1L throws an error because urlconf ( ver_caja ) expects an integer rather than the alphanumeric value " <int>L ".
All the information I received on the django docs site is (as an example in the tutorial), and this does not help:
... >>> p = Poll(question="What up?", pub_date=datetime.datetime.now())
So, how could I fix this to get caja.id=1 instead of caja.id=1L ?
Thanks in advance.
Pedro
EDIT: Here you have all the files.
template error:
Rendering exception showing: Reverse for 'ver_caja_chica' with arguments '(1L,)' and keyword Arguments '{}' not found.
Kaha / models.py
class Caja(models.Model): slug = models.SlugField(blank=True) nombre = models.CharField(max_length=20) saldo = models.DecimalField(max_digits=10, decimal_places=2) detalle = models.TextField(blank=True, null=True)
Kaha / urls.py
cajas_chicas = { 'queryset': CajaChica.objects.all(), } urlpatterns = patterns('', url(r'^$', 'django.views.generic.list_detail.object_list', dict(cajas_chicas, paginate_by=30), name="lista_cajas_chicas"), url(r'^(?P<object_id>\d+)/$', 'django.views.generic.list_detail.object_detail', dict(cajas_chicas, ), name="ver_caja_chica"), )
cajachica_list.html
... <table> {% for obj in object_list %} <tr class="{% cycle 'row1' 'row2' %}"> <td>{{ obj.nombre|capfirst }}</td> <td>{{ obj.fechahora_apert|timesince }}</td> <td>{{ obj.usuario_apert }}</td> <td>{{ obj.saldo }}</td> <td><a href="{% url ver_caja_chica obj.pk %}">Ver / Editar</a></td> </tr> {% endfor %} </table> ...
EDIT-2 With the wrong urlconf (as intended), this is the URL for this application:
... 4. ^caja/$ ^$ 5. ^caja/$ ^(?P<object_id>\d+)/$ ...
Perhaps the final URL was created incorrectly by django.
These URLs are inside caja / urls.py and included urls.py from the project root directory.
Some clues?