
    j                         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KJr  SSKJr   SS	 jrS
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)Promise)MAX_URL_REDIRECT_LENGTH)gettextNc                 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          H/var/www/html/KUNJ/venv/lib/python3.13/site-packages/django/shortcuts.pyrenderr      s#     %%mgSGv66    F)	permanentpreserve_request
max_lengthc                R    U(       a  [         O[        nU" [        U /UQ70 UD6UUS9$ )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. Set permanent=True to issue a
permanent redirect. Set preserve_request=True to instruct the user agent
to preserve the original HTTP method and body when following the redirect.
)r   r   )r   r   resolve_url)tor   r   r   argskwargsredirect_classs          r   redirectr"      s9    4 *3%8L  B((() 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(   B   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                   a6    [        [        S5      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_404r9   O   s     U#H8U##(55ENN5??;S;S 	 %'23
 	

||T,V,,>>&& 
 ./nn""../
 	

s   #A5 5AC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                   a6    [        [        S5      UR                  R                  R                  -  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 ''.Nr+   )r(   r%   r,   r-   r.   r/   r0   r;   r1   r2   r   r3   r4   r5   r6   s        r   aget_object_or_404r=   n   s     U#H8V$$(55ENN5??;S;S 	 )]".
 	

]]D3F3333>>&& 
./(..2F2F2R2RR
 	

s1   A#C&B ;B <B ?C B ACCc                 v   [        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(       d5  [        [        S5      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/   r0   listr?   r   r3   r1   r4   r5   )r'   r   r    r7   r8   obj_lists         r   get_list_or_404rB      s     U#H8X&&(55ENN5??;S;S 	 "$/0
 	
 HOOT4V45H./(..2F2F2R2RR
 	
 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(       d5  [        [        S5      UR                  R                  R                  -  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 'r<   Nr+   )r(   r%   r,   r-   r.   r/   r0   r?   r   r3   r1   r4   r5   )r'   r   r    r7   r8   objrA   s          r   aget_list_or_404rE      s     U#H8X&&(55ENN5??;S;S 	 )]".
 	
 &.__d%Ef%EFFcFFHF./(..2F2F2R2RR
 	
 Os7   A7C9B;B	?B
 B	BB		B
A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%   rG   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
   django.utils.httpr   django.utils.translationr   r3   r   r"   r(   r9   r=   rB   rE   r    r   r   <module>rU      s`     # / + 5 1 QU7 & F

>
&2&&r   