<s> from django . core . exceptions import ImproperlyConfigured , ObjectDoesNotExist <EOL> from django . views . generic import detail as detailview <EOL> from django . utils . translation import ugettext_lazy as _ <EOL> from django . http import Http404 <EOL> class SingleObjectMixin ( detailview . SingleObjectMixin ) : <EOL> document = None <EOL> def get_object ( self , queryset = None ) : <EOL> """<STR_LIT>""" <EOL> if queryset is None : <EOL> queryset = self . get_queryset ( ) <EOL> pk = self . kwargs . get ( '<STR_LIT>' , None ) <EOL> slug = self . kwargs . get ( '<STR_LIT>' , None ) <EOL> try : <EOL> if pk is not None : <EOL> return queryset . get ( pk = self . kwargs [ '<STR_LIT>' ] ) <EOL> elif slug is not None : <EOL> slug_field = self . get_slug_field ( ) <EOL> return queryset . get ( ** { slug_field : self . kwargs [ '<STR_LIT>' ] } ) <EOL> except ( ObjectDoesNotExist , IndexError ) : <EOL> raise Http404 ( _ ( u"<STR_LIT>" ) % <EOL> { '<STR_LIT>' : self . document . _meta . verbose_name } ) <EOL> def get_queryset ( self ) : <EOL> """<STR_LIT>""" <EOL> if self . queryset is not None : <EOL> queryset = self . queryset <EOL> if hasattr ( queryset , '<STR_LIT>' ) : <EOL> queryset = queryset . _clone ( ) <EOL> elif self . document is not None : <EOL> queryset = self . document . objects <EOL> else : <EOL> raise ImproperlyConfigured ( u"<STR_LIT>" <EOL> % self . __class__ . __name__ ) <EOL> return queryset <EOL> class BaseDetailView ( SingleObjectMixin , detailview . BaseDetailView ) : <EOL> pass <EOL> class DetailView ( BaseDetailView , detailview . SingleObjectTemplateResponseMixin ) : <EOL> pass <EOL> class SingleObjectTemplateResponseMixin ( SingleObjectMixin , detailview . SingleObjectTemplateResponseMixin ) : <EOL> pass </s>
