
    Evg                         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dS )    )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                 ,   ||                                  }| j                            | j                  }| j                            | j                  }||                    |          }|,|| j        r#|                                 } |j        di ||i}||t          d| j	        j
        z            	 |                                }nC# |j        j        $ r1 t          t          d          d|j        j        j        iz            w xY w|S )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.
        N)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         X/var/www/pixelcanvas.ch/venv/lib/python3.11/site-packages/django/views/generic/detail.py
get_objectzSingleObjectMixin.get_object   s@    ((**H [__T.//{t233>"--H t/E,,..J&x<<*d);<<H :$, /151HI  
	,,..CC~* 	 	 	@AA!8>#7#DEF  	
 
s   <C A Dc                     | j         C| j        r| j        j                                        S t	          dd| j        j        iz            | 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.
        Nzj%(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     = z z266888*.168O0P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                 n    | j         r| j         S t          |t          j                  r|j        j        S dS )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   s:    # 	++V\** 	9''4r+   c                     i }| j         r0| j         |d<   |                     | j                   }|r
| j         ||<   |                    |            t                      j        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\   sx    ; 	; $GH"&">">t{"K"K" ;/3{+,v'uww'22'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      s          EHJNL& & & &P# # #$    	3 	3 	3 	3 	3 	3 	3 	3 	3r+   r   c                       e Zd ZdZd ZdS )BaseDetailViewz+A base view for displaying a single object.c                     |                                  | _        |                     | j                  }|                     |          S )N)r4   )r%   r4   r7   render_to_response)r    requestargsr   r8   s        r$   r   zBaseDetailView.getk   s?    oo''''t{';;&&w///r+   N)r   r9   r:   r;   r   r   r+   r$   r?   r?   h   s)        550 0 0 0 0r+   r?   c                   &     e Zd ZdZdZ fdZ xZS )!SingleObjectTemplateResponseMixinN_detailc                    	 t                                                      }n# t          $ r g }| j        r:| j        r3t          | j        | j        d          }|r|                    d|           t          | j        t          j	                  r9| j        j
        }|                    |j        d|j        | j        d           npt          | dd          _t          | j        t          j	                  r@|                    | j        j
        j        d| j        j
        j        | j        d           |s Y nw xY w|S )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   *	GG..00EE# (	 (	 (	 E
 { *t7 *t{D,DdKK *LLD))) $+v|44 "k/ $---#..111	    w--9j
FL? ?9  
(222
(33111	     O(	T s    % DE E)r   r9   r:   rJ   rO   rI   r<   r=   s   @r$   rE   rE   q   sD        $6 6 6 6 6 6 6 6 6r+   rE   c                       e Zd ZdZdS )
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[      s.   7 7 7 7 7 7             1 1 1 1 1 1 O O O O O O O O O O]3 ]3 ]3 ]3 ]3 ]3 ]3 ]3@0 0 0 0 0& 0 0 0: : : : :(= : : :z    2N     r+   