Ticket/16418 #52

wants to merge 3 commits into


None yet
2 participants

dstufft commented May 9, 2012

Solves #16418 by explicitly checking for subclasses not assuming anything with a _meta or model attribute is a Model or QuerySet subclass.

names.append("%s/%s%s.html" % (
- elif hasattr(self, 'model') and hasattr(self.model, '_meta'):
+ elif hasattr(self, 'model') and self.model is not None and issubclass(self.model, models.Model):

akaariai May 27, 2012


why the is not None and issubclass check here instead of the normal isinstance?


dstufft May 30, 2012


These views allow passing either a model or a queryset. self.model is not an instance of a model but the actual model class and thus isinstance won't work. The None check is that if self.queryset is used instead of self.model, self.model will be None and the first arg to issubclass must be a class, not None.


akaariai commented Jun 8, 2012

Pulled in manually in commit 484fcd3. I removed the checks for isinstance(object_list, QuerySet) and retained the hasattr(object_list, 'model') instead because it seems lists containing attribute model are rare enough to not cause problems.

Thanks to dstufft for the patch! Unfortunately I forgot to thank him in the commit message, sorry for that.

@akaariai akaariai closed this Jun 8, 2012

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment