id,summary,reporter,owner,description,type,status,component,version,severity,resolution,keywords,cc,stage,has_patch,needs_docs,needs_tests,needs_better_patch,easy,ui_ux 21898,SingleObjectMixin should not require slug or pk if queryset is given,tomc,nobody,"I might be missing an obvious design decision made here, but it seems to me that if you give a queryset or define get_queryset() in a class with the SingleObjectMixin, that I shouldn't need to override get_object() and essentially dump the same code in but without checking for slug or pk. Simple use case: I'm rolling my own flatpages style app, different enough that I don't want to inherit from it. I'm not using the url as the pk as if someone typos the url the first time, they end up with two pages if they rename it. So my code ends up looking like this: {{{ class PageDetail(DetailView): def get_queryset(self): return Page.objects.filter(url=self.kwargs.get('url')) def get_object(self, queryset=None): if queryset is None: queryset = self.get_queryset() try: obj = queryset.get() except ObjectDoesNotExist: raise Http404('No %(verbose_name)s found matching the query' % {'verbose_name': queryset.model._meta.verbose_name}) return obj def get_template_names(self): return [self.object.template_name] }}} I feel like I should be able to just set the queryset without overriding get_object() Another option instead of removing the pk or slug check, might be to have a variable that sets the lookup field that can be anything, not just slug or pk, and if this isn't set, it reverts to the current behaviour I should be able to provide a patch for either case if necessary.",Cleanup/optimization,closed,Generic views,dev,Normal,worksforme,,,Unreviewed,0,0,0,0,0,0