
    k"g                         d dl mZ d dlmZ d dlmZ d dlmZ d dl	m
Z
mZmZ  G d de
      Z G d d	ee      Z G d
 de      Z G d dee      Zy)    )ImproperlyConfigured)models)Http404)gettext)ContextMixinTemplateResponseMixinViewc                   X     e Zd ZdZdZdZdZdZdZdZ	dZ
ddZd Zd Zd	 Z fd
Z xZS )SingleObjectMixinzS
    Provide the ability to retrieve a single object for further manipulation.
    NslugpkFc                 d   || j                         }| j                  j                  | j                        }| j                  j                  | j                        }||j                  |      }|2|| j                  r$| j                         } |j
                  di ||i}|$|"t        d| j                  j                  z        	 |j                         }|S # |j                  j                  $ r8 t        t        d      d|j                  j                  j                   iz        w xY w)z
        Return the object the view is displaying.

        Require `self.queryset` and a `pk` or `slug` argument in the URLconf.
        Subclasses can override this to return any object.
        )r   zXGeneric detail view %s must be called with either an object pk or a slug in the URLconf.z,No %(verbose_name)s found matching the queryverbose_name )get_querysetkwargsgetpk_url_kwargslug_url_kwargfilterquery_pk_and_slugget_slug_fieldAttributeError	__class____name__modelDoesNotExistr   __metar   )selfquerysetr   r   
slug_fieldobjs         T/var/www/html/djangosite/lib/python3.12/site-packages/django/views/generic/detail.py
get_objectzSingleObjectMixin.get_object   s/    ((*H [[__T../{{t223>"-H t/E/E,,.J&x<*d);<H :$, /151H1HI 
	,,.C 
 ~~** 	@A!8>>#7#7#D#DEF 	s   C AD/c                     | j                   T| j                  r$| j                  j                  j                         S t	        dd| j
                  j                  iz        | j                   j                         S )z
        Return the `QuerySet` that will be used to look up the object.

        This method is called by the default implementation of get_object() and
        may not be called if get_object() is overridden.
        zj%(cls)s is missing a QuerySet. Define %(cls)s.model, %(cls)s.queryset, or override %(cls)s.get_queryset().cls)r!   r   _default_managerallr   r   r   r    s    r$   r   zSingleObjectMixin.get_queryset=   sm     == zzzz226688*.168O8O0PQ 
 }}  ""    c                     | j                   S )z;Get the name of a slug field to be used to look up by slug.)r"   r*   s    r$   r   z SingleObjectMixin.get_slug_fieldO   s    r+   c                     | j                   r| j                   S t        |t        j                        r|j                  j
                  S y)z#Get the name to use for the object.N)context_object_name
isinstancer   Modelr   
model_name)r    r#   s     r$   get_context_object_namez)SingleObjectMixin.get_context_object_nameS   s8    ##+++V\\*99'''r+   c                     i }| j                   r;| j                   |d<   | j                  | j                         }|r| j                   ||<   |j                  |       t        |   di |S )z/Insert the single object into the context dict.objectr   )r4   r2   updatesuperget_context_data)r    r   contextr.   r   s       r$   r7   z"SingleObjectMixin.get_context_data\   sc    ;; $GH"&">">t{{"K"/3{{+,vw'2'22r+   )N)r   
__module____qualname____doc__r   r!   r"   r.   r   r   r   r%   r   r   r2   r7   __classcell__r   s   @r$   r   r      sN     EHJNL&P#$	3 	3r+   r   c                       e Zd ZdZd Zy)BaseDetailViewz+A base view for displaying a single object.c                     | j                         | _        | j                  | j                        }| j                  |      S )N)r4   )r%   r4   r7   render_to_response)r    requestargsr   r8   s        r$   r   zBaseDetailView.getk   s8    oo'''t{{';&&w//r+   N)r   r9   r:   r;   r   r   r+   r$   r?   r?   h   s
    50r+   r?   c                   &     e Zd ZdZdZ fdZ xZS )!SingleObjectTemplateResponseMixinN_detailc                    	 t         |          }|S # t        $ rX g }| j                  rA| j                  r5t        | j                  | j                  d      }|r|j                  d|       t        | j                  t        j                        rN| j                  j                  }|j                  |j                  d|j                  | j                  d       nt        | dd      t        | j                   t        j                        r_|j                  | j                   j                  j                  d| j                   j                  j                  | j                  d       |s Y |S w xY w)a  
        Return a list of template names to be used for the request. May not be
        called if render_to_response() is overridden. Return the following list:

        * the value of ``template_name`` on the view (if provided)
        * the contents of the ``template_name_field`` field on the
          object instance that the view is operating upon (if available)
        * ``<app_label>/<model_name><template_name_suffix>.html``
        Nr   /z.htmlr   )r6   get_template_namesr   r4   template_name_fieldgetattrinsertr/   r   r0   r   append	app_labelr1   template_name_suffix
issubclassr   )r    namesnameobject_metar   s       r$   rI   z4SingleObjectTemplateResponseMixin.get_template_namesu   s?   *	G.0EV U $ (	 E
 {{t77t{{D,D,DdKLLD) $++v||4"kk// $--#..11	 w-9j

FLL?  

((22

((3311	   U(	s    EE54E5)r   r9   r:   rJ   rO   rI   r<   r=   s   @r$   rE   rE   q   s    $6 6r+   rE   c                       e Zd ZdZy)
DetailViewz
    Render a "detail" view of an object.

    By default this is a model instance looked up from `self.queryset`, but the
    view will support display of *any* object by overriding `self.get_object()`.
    N)r   r9   r:   r;   r   r+   r$   rU   rU      s    r+   rU   N)django.core.exceptionsr   	django.dbr   django.httpr   django.utils.translationr   r   django.views.generic.baser   r   r	   r   r?   rE   rU   r   r+   r$   <module>r[      sR    7   1 O O]3 ]3@0& 0:(= :z2N r+   