Hi guys, im trying to make Categories and Subcategories, im checking this models but i have this error:
Truncated incorrect DOUBLE value: 'nacionales'
where the "nacionales" is the parent Category, i know that my problem maybe are in the urls.py, but the true, i dont know how set the urls for this case...
my model.py:
# from ...
class Categoria(models.Model):
titulo = models.CharField(max_length=75, unique=True)
slug = models.SlugField(max_length=200,unique=True)
parent = models.ForeignKey('self', blank=True, null=True, related_name='child')
# functions....
my views.py:
# from ...
def noticias_categoria(request,parent_id,child):
categoria = get_object_or_404(Categoria,parent=parent_id,slug=child)
return object_list(request, queryset=categoria.noticia_set.all(), paginate_by=20,
template_name='categorias/categoria_list.html',
extra_context={'categoria':categoria})
my Category urls.py:
# from ...
url(r'^(?P<parent_id>[-\w]+)/(?P<child>[-\w]+)/$',
noticias_categoria,
name='noticia_detail'
),
my url.py:
(r'^categorias/', include('categorias.urls')),
Thanks guys