Solution: you need to rename slug parameter in url to other name, or in your view set slug_url_kwarg some other value - not 'slug'
Explanation: When you add to url, django tries to get object by slug and your model Detail has no slug field.
Link to django code: https://github.com/django/django/blob/master/django/views/generic/detail.py#L33
UPDATE
in SingleObjectMixin:
slug = self.kwargs.get(self.slug_url_kwarg, None)
...
elif slug is not None:
slug_field = self.get_slug_field()
queryset = queryset.filter(**{slug_field: slug})
so django gets slug from your url, tries to get slug field from Detail model and fails
Your view need to rewrite slug_url_kwarg attribute:
class ArticleDetail(DetailView):
model = Detail
template_name = "article_detail.html"
context_object_name = "details"
slug_url_kwarg = "not_slug" # this attribute
def get_queryset(self):
print self.kwargs['slug']
a = Article.objects.get(slug=self.kwargs['slug'])
# print Details.object.get()
# print Detail.objects.filter(article__slug=self.kwargs['slug']) fails with same error
return Detail.objects.filter(article=a)
but I think better way is to change to attribute in your url:
url(r'^(?P<id>\d+)/(?P<article_slug>[-\w\d]+)/$', ArticleDetail.as_view(), name='article_detail'),
and get article_slug from view kwargs