Ë
    aõhi‘  ã                   óv   — d Z ddlmZmZmZmZ ddlmZ ddlm	Z	m
Z
 ddlmZ 	 dd„Zdd	œd
„Zd„ Zd„ Zd„ Zd„ Zy)zµ
This module collects helper functions and classes that "span" multiple levels
of MVC. In other words, these functions/classes introduce controlled coupling
for convenience's sake.
é    )ÚHttp404ÚHttpResponseÚHttpResponsePermanentRedirectÚHttpResponseRedirect)Úloader)ÚNoReverseMatchÚreverse)ÚPromiseNc                 óN   — t        j                  ||| |¬«      }t        |||«      S )zœ
    Return an HttpResponse whose content is filled with the result of calling
    django.template.loader.render_to_string() with the passed arguments.
    )Úusing)r   Úrender_to_stringr   )ÚrequestÚtemplate_nameÚcontextÚcontent_typeÚstatusr   Úcontents          úF/var/www/alwasay/venv/lib/python3.12/site-packages/django/shortcuts.pyÚrenderr      s)   € ô ×%Ñ% m°W¸gÈUÔS€GÜ˜ ¨vÓ6Ð6ó    F)Ú	permanentc                óH   — |rt         nt        } |t        | g|¢­i |¤Ž«      S )aè  
    Return an HttpResponseRedirect to the appropriate URL for the arguments
    passed.

    The arguments could be:

        * A model: the model's `get_absolute_url()` function will be called.

        * A view name, possibly with arguments: `urls.reverse()` will be used
          to reverse-resolve the name.

        * A URL, which will be used as-is for the redirect location.

    Issues a temporary redirect by default; pass permanent=True to issue a
    permanent redirect.
    )r   r   Úresolve_url)Útor   ÚargsÚkwargsÚredirect_classs        r   Úredirectr      s.   € ñ$ *3Õ%Ô8Lð ñ œ+ bÐ:¨4Ò:°6Ñ:Ó;Ð;r   c                 óR   — t        | d«      r| j                  j                  «       S | S )zÃ
    Return a QuerySet or a Manager.
    Duck typing in action: any class with a `get()` method (for
    get_object_or_404) or a `filter()` method (for get_list_or_404) might do
    the job.
    Ú_default_manager)Úhasattrr    Úall)Úklasss    r   Ú_get_querysetr$   3   s)   € ô ˆuÐ(Ô)Ø×%Ñ%×)Ñ)Ó+Ð+Ø€Lr   c                 óh  — t        | «      }t        |d«      s@t        | t        «      r| j                  n| j
                  j                  }t        d|z  «      ‚	  |j                  |i |¤ŽS # |j                  j                  $ r- t        d|j                  j                  j                  z  «      ‚w xY w)aY  
    Use get() to return an object, or raise an Http404 exception if the object
    does not exist.

    klass may be a Model, Manager, or QuerySet object. All other passed
    arguments and keyword arguments are used in the get() query.

    Like with QuerySet.get(), MultipleObjectsReturned is raised if more than
    one object is found.
    ÚgetzVFirst argument to get_object_or_404() must be a Model, Manager, or QuerySet, not '%s'.úNo %s matches the given query.)r$   r!   Ú
isinstanceÚtypeÚ__name__Ú	__class__Ú
ValueErrorr&   ÚmodelÚDoesNotExistr   Ú_metaÚobject_name)r#   r   r   ÚquerysetÚklass__names        r   Úget_object_or_404r3   @   s®   € ô ˜UÓ#€HÜ�8˜UÔ#ä(¨´Ô5ˆE�NŠN¸5¿?¹?×;SÑ;Sð 	ô ð%Ø'2ñ3ó
ð 	
ð
Øˆx�|‰|˜TÐ, VÑ,Ð,øØ�>‰>×&Ñ&ò 
ÜØ,¨x¯~©~×/CÑ/C×/OÑ/OÑOó
ð 	
ð
ús   ÁA+ Á+AB1c                 óF  — t        | «      }t        |d«      s@t        | t        «      r| j                  n| j
                  j                  }t        d|z  «      ‚t         |j                  |i |¤Ž«      }|s,t        d|j                  j                  j                  z  «      ‚|S )zø
    Use filter() to return a list of objects, or raise an Http404 exception if
    the list is empty.

    klass may be a Model, Manager, or QuerySet object. All other passed
    arguments and keyword arguments are used in the filter() query.
    ÚfilterzTFirst argument to get_list_or_404() must be a Model, Manager, or QuerySet, not '%s'.r'   )r$   r!   r(   r)   r*   r+   r,   Úlistr5   r   r-   r/   r0   )r#   r   r   r1   r2   Úobj_lists         r   Úget_list_or_404r8   \   s    € ô ˜UÓ#€HÜ�8˜XÔ&ä(¨´Ô5ˆE�NŠN¸5¿?¹?×;SÑ;Sð 	ô ð"Ø$/ñ0ó
ð 	
ô �O�H—O‘O TÐ4¨VÑ4Ó5€HÙÜØ,¨x¯~©~×/CÑ/C×/OÑ/OÑOó
ð 	
ð €Or   c                 ó  — t        | d«      r| j                  «       S t        | t        «      rt	        | «      } t        | t        «      r| j                  d«      r| S 	 t        | ||¬«      S # t        $ r t        | «      r‚ d| vrd| vr‚ Y | S w xY w)aM  
    Return a URL appropriate for the arguments passed.

    The arguments could be:

        * A model: the model's `get_absolute_url()` function will be called.

        * A view name, possibly with arguments: `urls.reverse()` will be used
          to reverse-resolve the name.

        * A URL, which will be returned as-is.
    Úget_absolute_url)z./z../)r   r   ú/ú.)	r!   r:   r(   r
   ÚstrÚ
startswithr	   r   Úcallable)r   r   r   s      r   r   r   u   s”   € ô ˆrÐ%Ô&Ø×"Ñ"Ó$Ð$ä�"”gÔô �‹Wˆô �"”cÔ˜rŸ}™}¨]Ô;Øˆ	ðÜ�r ¨VÔ4Ð4øÜò ä�BŒ<Øà�b‰=˜S¨™]Øøð €Iðús   ÁA* Á*BÂB)NNNN)Ú__doc__Údjango.httpr   r   r   r   Údjango.templater   Údjango.urlsr   r	   Údjango.utils.functionalr
   r   r   r$   r3   r8   r   © r   r   ú<module>rF      sI   ðñ÷
ó õ #ß /Ý +ð QUó7ð #(ô <ò.
ò
ò8ó2&r   