
    h                         S r SSKJrJrJrJr  SSKJr  SSKJ	r	J
r
  SSKJr   SS jrSS	.S
 jrS rS rS rS rS rS rg)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                 D    [         R                  " XXS9n[        XcU5      $ )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          B/var/www/html/env/lib/python3.13/site-packages/django/shortcuts.pyrenderr      s#     %%mgSGv66    F)	permanentc                R    U(       a  [         O[        nU" [        U /UQ70 UD65      $ )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                 \    [        U S5      (       a  U R                  R                  5       $ U $ )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$   4   s,     u())%%))++Lr   c                 ~   [        U 5      n[        US5      (       dE  [        U [        5      (       a  U R                  OU R
                  R                  n[        SU-  5      e UR                  " U0 UD6$ ! UR                  R                   a-    [        SUR                  R                  R                  -  5      ef = f)a=  
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_404r4   A   s     U#H8U##(55ENN5??;S;S 	 %'23
 	

||T,V,,>>&& 
,x~~/C/C/O/OO
 	

s   #A5 5AB<c                   #    [        U 5      n[        US5      (       dF  [        U [        5      (       a  U R                  OU R
                  R                  n[        SU S35      e UR                  " U0 UD6I Sh  vN $  N! UR                  R                   a.    [        SUR                  R                  R                   S35      ef = f7f)zSee get_object_or_404().agetzSFirst argument to aget_object_or_404() must be a Model, Manager, or QuerySet, not ''.NNo  matches the given query.)r$   r!   r(   r)   r*   r+   r,   r6   r-   r.   r   r/   r0   r1   s        r   aget_object_or_404r:   ]   s     U#H8V$$(55ENN5??;S;S 	 )]".
 	
Y]]D3F3333>>&& YHNN00<<==VWXXYs1   A#C&B ;B <B ?C B AC

Cc                 d   [        U 5      n[        US5      (       dE  [        U [        5      (       a  U R                  OU R
                  R                  n[        SU-  5      e[        UR                  " U0 UD65      nU(       d,  [        SUR                  R                  R                  -  5      eU$ )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,   listr<   r   r-   r/   r0   )r#   r   r   r2   r3   obj_lists         r   get_list_or_404r?   n   s     U#H8X&&(55ENN5??;S;S 	 "$/0
 	
 HOOT4V45H,x~~/C/C/O/OO
 	
 Or   c                   #    [        U 5      n[        US5      (       dF  [        U [        5      (       a  U R                  OU R
                  R                  n[        SU S35      eUR                  " U0 UD6 Vs/ s Sh  vN oUPM   N
 Os  snf nnU(       d-  [        SUR                  R                  R                   S35      eU$ 7f)zSee get_list_or_404().r<   zQFirst argument to aget_list_or_404() must be a Model, Manager, or QuerySet, not 'r7   Nr8   r9   )r$   r!   r(   r)   r*   r+   r,   r<   r   r-   r/   r0   )r#   r   r   r2   r3   objr>   s          r   aget_list_or_404rB      s     U#H8X&&(55ENN5??;S;S 	 )]".
 	
 &.__d%Ef%EFFcFFHFHNN00<<==VWXXOs6   A7C9B;B	?B
 B	BB		B
>Cc                 R   [        U S5      (       a  U R                  5       $ [        U [        5      (       a  [	        U 5      n [        U [        5      (       a  U R                  S5      (       a  U $  [        XUS9$ ! [         a"    [        U 5      (       a  e SU ;  a  SU ;  a  e  U $ f = f)a1  
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!   rD   r(   r
   str
startswithr	   r   callable)r   r   r   s      r   r   r      s     r%&&""$$"g W "cr}}];;	rV44 B<<b=S] Is   0	A: :(B&%B&)NNNN)__doc__django.httpr   r   r   r   django.templater   django.urlsr   r	   django.utils.functionalr
   r   r   r$   r4   r:   r?   rB   r    r   r   <module>rP      sT     # / + QU7 #( <.

8Y"2"&r   