ó
­â0_c           @  s;  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 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 d  d l m Z d „  Z d „  Z d e f d „  ƒ  YZ d e f d „  ƒ  YZ d e f d „  ƒ  YZ d „  Z  d „  Z! d „  Z" d S(   iÿÿÿÿ(   t   unicode_literals(   t   chain(   t   apps(   t   settings(   t   NotRelationFieldt   flattent   get_fields_from_path(   t   checks(   t   FieldDoesNotExist(   t   models(   t
   LOOKUP_SEP(   t   BaseModelFormt   BaseModelFormSett   _get_foreign_key(   t   Enginec         K  sA   d d l  m } g  } x$ | D] } | j | j |  ƒ ƒ q W| S(   Niÿÿÿÿ(   t	   all_sites(   t   django.contrib.admin.sitesR   t   extendt   check(   t   app_configst   kwargsR   t   errorst   site(    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyt   check_admin_app   s
    c          K  s¥   g  } t  j d ƒ s: t j d d d ƒ} | j | ƒ n  y t j ƒ  } Wn t k
 r] nD Xd | j k r¡ d t	 j
 k r¡ t j d d d ƒ} | j | ƒ n  | S(	   uF   
    Check that the admin's dependencies are correctly installed.
    u   django.contrib.contenttypesu^   'django.contrib.contenttypes' must be in INSTALLED_APPS in order to use the admin application.t   idu
   admin.E401u+   django.contrib.auth.context_processors.authu)   django.contrib.auth.backends.ModelBackendui   'django.contrib.auth.context_processors.auth' must be in TEMPLATES in order to use the admin application.u
   admin.E402(   R   t   is_installedR   t   Errort   appendR   t   get_defaultt	   Exceptiont   context_processorsR   t   AUTHENTICATION_BACKENDS(   R   R   t   missing_appt   default_template_enginet   missing_template(    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyt   check_dependencies   s$    		t   BaseModelAdminChecksc           B  sé   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         K  s  g  } | j  |  j | ƒ ƒ | j  |  j | ƒ ƒ | j  |  j | ƒ ƒ | j  |  j | ƒ ƒ | j  |  j | ƒ ƒ | j  |  j | ƒ ƒ | j  |  j | ƒ ƒ | j  |  j | ƒ ƒ | j  |  j	 | ƒ ƒ | j  |  j
 | ƒ ƒ | j  |  j | ƒ ƒ | j  |  j | ƒ ƒ | S(   N(   R   t   _check_raw_id_fieldst   _check_fieldst   _check_fieldsetst   _check_excludet   _check_formt   _check_filter_verticalt   _check_filter_horizontalt   _check_radio_fieldst   _check_prepopulated_fieldst   _check_view_on_site_urlt   _check_orderingt   _check_readonly_fields(   t   selft	   admin_objR   R   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR   F   s    c      
   C  sƒ   t  | j t t f ƒ s4 t d d d d | d d ƒSt t g  t | j ƒ D]+ \ } } |  j | | j | d | ƒ ^ qJ Œ  ƒ Sd S(	   u\    Check that `raw_id_fields` only contains field names that are listed
        on the model. u   a list or tuplet   optionu   raw_id_fieldst   objR   u
   admin.E001u   raw_id_fields[%d]N(	   t
   isinstancet   raw_id_fieldst   listt   tuplet   must_beR   t	   enumeratet   _check_raw_id_fields_itemt   model(   R1   R4   t   indext
   field_name(    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR%   V   s
    c         C  s   y | j  j | ƒ } Wn3 t k
 rK t d | d | d | d | d d ƒ SX| j r… t | t j ƒ r… t d d | d | d d ƒSg  Sd	 S(
   už    Check an item of `raw_id_fields`, i.e. check that field named
        `field_name` exists in model `model` and is a ForeignKey or a
        ManyToManyField. t   fieldR3   R<   R4   R   u
   admin.E002u%   a foreign key or a many-to-many fieldu
   admin.E003N(	   t   _metat	   get_fieldR   t   refer_to_missing_fieldt   many_to_manyR5   R	   t
   ForeignKeyR9   (   R1   R4   R<   R>   t   labelR?   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR;   b   s    	c      	   C  sö   | j  d k r g  St | j  t t f ƒ sG t d d d d | d d ƒS| j ro t j d d | j	 d d ƒg St
 | j  ƒ } t | ƒ t t | ƒ ƒ k r» t j d	 d | j	 d d
 ƒg St t g  | j  D]! } |  j | | j | d ƒ ^ qË Œ  ƒ S(   u    Check that `fields` only refer to existing fields, doesn't contain
        duplicates. Check if at most one of `fields` and `fieldsets` is defined.
        u   a list or tupleR3   u   fieldsR4   R   u
   admin.E004u,   Both 'fieldsets' and 'fields' are specified.u
   admin.E005u2   The value of 'fields' contains duplicate field(s).u
   admin.E006N(   t   fieldst   NoneR5   R7   R8   R9   t	   fieldsetsR   R   t	   __class__R   t   lent   setR   t   _check_field_specR<   (   R1   R4   RF   R>   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR&   s   s$    		
	
c      
   C  s–   | j  d k r g  St | j  t t f ƒ sG t d d d d | d d ƒSt t g  t | j  ƒ D]+ \ } } |  j | | j	 | d | ƒ ^ q] Œ  ƒ Sd S(	   uT    Check that fieldsets is properly formatted and doesn't contain
        duplicates. u   a list or tupleR3   u	   fieldsetsR4   R   u
   admin.E007u   fieldsets[%d]N(
   RH   RG   R5   R7   R8   R9   R   R:   t   _check_fieldsets_itemR<   (   R1   R4   R=   t   fieldset(    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR'   “   s    c      
   C  s˜  t  | t t f ƒ s1 t d d | d | d d ƒSt | ƒ d k r_ t d d | d | d d ƒSt  | d	 t ƒ s’ t d
 d d | d | d d ƒSd | d	 k rÅ t j d | d | j d d ƒg St  | d	 d t t f ƒ st d d d | d | d d ƒSt	 | d	 d ƒ } t | ƒ t t
 | ƒ ƒ k rWt j d | d | j d d ƒg St t g  | d	 d D]" } |  j | | | d | ƒ ^ qlŒ  ƒ S(   u~    Check an item of `fieldsets`, i.e. check that this is a pair of a
        set name and a dictionary containing "fields" key. u   a list or tupleR3   R4   R   u
   admin.E008i   u   of length 2u
   admin.E009i   u   a dictionaryu   %s[1]u
   admin.E010u   fieldsu3   The value of '%s[1]' must contain the key 'fields'.u
   admin.E011u   %s[1]['fields']u(   There are duplicate field(s) in '%s[1]'.u
   admin.E012u   %s[1]["fields"](   R5   R7   R8   R9   RJ   t   dictR   R   RI   R   RK   R   RL   (   R1   R4   R<   RN   RE   RF   t   fieldset_fields(    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRM   ¡   s,     
	
 
	
c         C  st   t  | t ƒ rZ t t g  t | ƒ D]. \ } } |  j | | | d | | f ƒ ^ q" Œ  ƒ S|  j | | | | ƒ Sd S(   u´    `fields` should be an item of `fields` or an item of
        fieldset[1]['fields'] for any `fieldset` in `fieldsets`. It should be a
        field name or a tuple of field names. u   %s[%d]N(   R5   R8   R7   R   R:   t   _check_field_spec_item(   R1   R4   R<   RF   RE   R=   R>   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRL   Ä   s
    Bc         C  s”   | | j  k r g  Sy | j j | ƒ } Wn t k
 r= g  SXt | t j ƒ rŒ | j j j j	 rŒ t
 j d | | f d | j d d ƒg Sg  Sd  S(   Nuv   The value of '%s' cannot include the ManyToManyField '%s', because that field manually specifies a relationship model.R4   R   u
   admin.E013(   t   readonly_fieldsR@   RA   R   R5   R	   t   ManyToManyFieldt   remote_fieldt   throught   auto_createdR   R   RI   (   R1   R4   R<   R>   RE   R?   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRQ   Ñ   s    	
c         C  s’   | j  d	 k r g  St | j  t t f ƒ sG t d d d d | d d ƒSt | j  ƒ t t | j  ƒ ƒ k rŠ t j	 d d | j
 d d ƒg Sg  Sd	 S(
   u6    Check that exclude is a sequence without duplicates. u   a list or tupleR3   u   excludeR4   R   u
   admin.E014u3   The value of 'exclude' contains duplicate field(s).u
   admin.E015N(   t   excludeRG   R5   R7   R8   R9   RJ   RK   R   R   RI   (   R1   R4   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR(   í   s    $	
c      	   C  sI   t  | d ƒ rA t | j t ƒ rA t d d d d d | d d ƒ Sg  Sd S(	   u+    Check that form subclasses BaseModelForm. u   formt   parentu   BaseModelFormR3   R4   R   u
   admin.E016N(   t   hasattrt
   issubclasst   formR   t   must_inherit_from(   R1   R4   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR)   ÿ   s    "c      
   C  s–   t  | d ƒ s g  St | j t t f ƒ sG t d d d d | d d ƒSt t g  t | j ƒ D]+ \ } } |  j | | j	 | d | ƒ ^ q] Œ  ƒ Sd S(	   u:    Check that filter_vertical is a sequence of field names. u   filter_verticalu   a list or tupleR3   R4   R   u
   admin.E017u   filter_vertical[%d]N(
   RY   R5   t   filter_verticalR7   R8   R9   R   R:   t   _check_filter_itemR<   (   R1   R4   R=   R>   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR*     s    c      
   C  s–   t  | d ƒ s g  St | j t t f ƒ sG t d d d d | d d ƒSt t g  t | j ƒ D]+ \ } } |  j | | j	 | d | ƒ ^ q] Œ  ƒ Sd S(	   u<    Check that filter_horizontal is a sequence of field names. u   filter_horizontalu   a list or tupleR3   R4   R   u
   admin.E018u   filter_horizontal[%d]N(
   RY   R5   t   filter_horizontalR7   R8   R9   R   R:   R^   R<   (   R1   R4   R=   R>   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR+     s    c         C  sy   y | j  j | ƒ } Wn3 t k
 rK t d | d | d | d | d d ƒ SX| j sq t d d | d | d d ƒSg  Sd	 S(
   u‚    Check one item of `filter_vertical` or `filter_horizontal`, i.e.
        check that given field exists and is a ManyToManyField. R?   R3   R<   R4   R   u
   admin.E019u   a many-to-many fieldu
   admin.E020N(   R@   RA   R   RB   RC   R9   (   R1   R4   R<   R>   RE   R?   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR^   "  s    	c      
   C  s£   t  | d ƒ s g  St | j t ƒ sA t d d d d | d d ƒSt t g  | j j ƒ  D]> \ } } |  j | | j	 | d ƒ |  j
 | | d | ƒ ^ qW Œ  ƒ Sd S(	   u,    Check that `radio_fields` is a dictionary. u   radio_fieldsu   a dictionaryR3   R4   R   u
   admin.E021u   radio_fields["%s"]N(   RY   R5   t   radio_fieldsRO   R9   R7   R   t   itemst   _check_radio_fields_keyR<   t   _check_radio_fields_value(   R1   R4   R>   t   val(    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR,   1  s    c         C  s˜   y | j  j | ƒ } Wn3 t k
 rK t d | d | d | d | d d ƒ SXt | t j ƒ pd | j s t j	 d | | f d | j
 d d ƒg Sg  Sd	 S(
   uŽ    Check that a key of `radio_fields` dictionary is name of existing
        field and that the field is a ForeignKey or has `choices` defined. R?   R3   R<   R4   R   u
   admin.E022us   The value of '%s' refers to '%s', which is not an instance of ForeignKey, and does not have a 'choices' definition.u
   admin.E023N(   R@   RA   R   RB   R5   R	   RD   t   choicesR   R   RI   (   R1   R4   R<   R>   RE   R?   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRb   ?  s    	
c         C  sS   d d l  m } m } | | | f k rK t j d | d | j d d ƒg Sg  Sd S(   u5    Check type of a value of `radio_fields` dictionary. iÿÿÿÿ(   t
   HORIZONTALt   VERTICALuD   The value of '%s' must be either admin.HORIZONTAL or admin.VERTICAL.R4   R   u
   admin.E024N(   t   django.contrib.admin.optionsRf   Rg   R   R   RI   (   R1   R4   Rd   RE   Rf   Rg   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRc   W  s    
	
c         C  s`   t  | d ƒ rX t | j ƒ rQ t | j t ƒ rQ t j d d | j d d ƒg Sg  Sn g  Sd  S(   Nu   view_on_siteuB   The value of 'view_on_site' must be a callable or a boolean value.R4   R   u
   admin.E025(   RY   t   callablet   view_on_siteR5   t   boolR   R   RI   (   R1   R4   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR.   g  s    #	
c         C  s©   t  | d ƒ s g  St | j t ƒ sA t d d d d | d d ƒSt t g  | j j ƒ  D]D \ } } |  j | | j	 | d ƒ |  j
 | | j	 | d | ƒ ^ qW Œ  ƒ Sd S(	   uZ    Check that `prepopulated_fields` is a dictionary containing allowed
        field types. u   prepopulated_fieldsu   a dictionaryR3   R4   R   u
   admin.E026u   prepopulated_fields["%s"]N(   RY   R5   t   prepopulated_fieldsRO   R9   R7   R   Ra   t   _check_prepopulated_fields_keyR<   t    _check_prepopulated_fields_value(   R1   R4   R>   Rd   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR-   v  s    c         C  sž   y | j  j | ƒ } Wn3 t k
 rK t d | d | d | d | d d ƒ SXt | t j t j t j f ƒ r– t	 j
 d | | f d | j d d ƒg Sg  Sd	 S(
   uœ    Check a key of `prepopulated_fields` dictionary, i.e. check that it
        is a name of existing field and the field is one of the allowed types.
        R?   R3   R<   R4   R   u
   admin.E027uy   The value of '%s' refers to '%s', which must not be a DateTimeField, a ForeignKey, a OneToOneField, or a ManyToManyField.u
   admin.E028N(   R@   RA   R   RB   R5   R	   t   DateTimeFieldRD   RS   R   R   RI   (   R1   R4   R<   R>   RE   R?   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRm   …  s    !	
c         C  s€   t  | t t f ƒ s1 t d d | d | d d ƒSt t g  t | ƒ D]. \ } } |  j | | | d | | f ƒ ^ qD Œ  ƒ Sd S(   uf    Check a value of `prepopulated_fields` dictionary, i.e. it's an
        iterable of existing fields. u   a list or tupleR3   R4   R   u
   admin.E029u   %s[%r]N(   R5   R7   R8   R9   R   R:   t%   _check_prepopulated_fields_value_item(   R1   R4   R<   Rd   RE   R=   t   subfield_name(    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRn   œ  s
    c         C  sR   y | j  j | ƒ Wn3 t k
 rI t d | d | d | d | d d ƒ SXg  Sd S(   u[    For `prepopulated_fields` equal to {"slug": ("title",)},
        `field_name` is "title". R?   R3   R<   R4   R   u
   admin.E030N(   R@   RA   R   RB   (   R1   R4   R<   R>   RE   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRp   ¨  s
    &c      
   C  s–   | j  d k r g  St | j  t t f ƒ sG t d d d d | d d ƒSt t g  t | j  ƒ D]+ \ } } |  j | | j	 | d | ƒ ^ q] Œ  ƒ Sd S(	   u=    Check that ordering refers to existing fields or is random. u   a list or tupleR3   u   orderingR4   R   u
   admin.E031u   ordering[%d]N(
   t   orderingRG   R5   R7   R8   R9   R   R:   t   _check_ordering_itemR<   (   R1   R4   R=   R>   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR/   ³  s    c         C  sä   | d k rF t  | j ƒ d k rF t j d d d d | j d d ƒg S| d k rV g  St | k rf g  S| j d	 ƒ r‚ | d } n  | d
 k r’ g  Sy | j j | ƒ Wn3 t	 k
 rÛ t
 d | d | d | d | d d ƒ SXg  Sd S(   u2    Check that `ordering` refers to existing fields. u   ?i   u^   The value of 'ordering' has the random ordering marker '?', but contains other fields as well.t   hintu2   Either remove the "?", or remove the other fields.R4   R   u
   admin.E032u   -u   pkR?   R3   R<   u
   admin.E033N(   RJ   Rr   R   R   RI   R
   t
   startswithR@   RA   R   RB   (   R1   R4   R<   R>   RE   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRs   Á  s&    !	
&c      
   C  s–   | j  d	 k r g  St | j  t t f ƒ sG t d d d d | d d ƒSt t g  t | j  ƒ D]+ \ } } |  j | | j | d | ƒ ^ q] Œ  ƒ Sd S(
   uA    Check that readonly_fields refers to proper attribute or field. u   a list or tupleR3   u   readonly_fieldsR4   R   u
   admin.E034u   readonly_fields[%d]N(    (	   RR   R5   R7   R8   R9   R   R:   t   _check_readonly_fields_itemR<   (   R1   R4   R=   R>   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR0   à  s    c         C  s¤   t  | ƒ r g  St | | ƒ r# g  St | | ƒ r6 g  Sy | j j | ƒ WnO t k
 r› t j d | | j j | j j	 | j j
 f d | j d d ƒg SXg  Sd  S(   NuV   The value of '%s' is not a callable, an attribute of '%s', or an attribute of '%s.%s'.R4   R   u
   admin.E035(   Ri   RY   R@   RA   R   R   R   RI   t   __name__t	   app_labelt   object_name(   R1   R4   R<   R>   RE   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRv   í  s    %	(   Rw   t
   __module__R   R%   R;   R&   R'   RM   RL   RQ   R(   R)   R*   R+   R^   R,   Rb   Rc   R.   R-   Rm   Rn   Rp   R/   Rs   R0   Rv   (    (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR$   D   s2   				 		#																			t   ModelAdminChecksc           B  sª   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d	 „  Z d
 „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         K  s$  t  t |  ƒ j | ƒ } | j |  j | ƒ ƒ | j |  j | ƒ ƒ | j |  j | ƒ ƒ | j |  j | ƒ ƒ | j |  j | ƒ ƒ | j |  j	 | ƒ ƒ | j |  j
 | ƒ ƒ | j |  j | ƒ ƒ | j |  j | ƒ ƒ | j |  j | ƒ ƒ | j |  j | ƒ ƒ | j |  j | ƒ ƒ | S(   N(   t   superR{   R   R   t   _check_save_ast   _check_save_on_topt   _check_inlinest   _check_list_displayt   _check_list_display_linkst   _check_list_filtert   _check_list_select_relatedt   _check_list_per_paget   _check_list_max_show_allt   _check_list_editablet   _check_search_fieldst   _check_date_hierarchy(   R1   R2   R   R   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR     s    c         C  s6   t  | j t ƒ s. t d d d d | d d ƒSg  Sd S(   u    Check save_as is a boolean. u	   a booleanR3   u   save_asR4   R   u
   admin.E101N(   R5   t   save_asRk   R9   (   R1   R4   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR}     s    c         C  s6   t  | j t ƒ s. t d d d d | d d ƒSg  Sd S(   u!    Check save_on_top is a boolean. u	   a booleanR3   u   save_on_topR4   R   u
   admin.E102N(   R5   t   save_on_topRk   R9   (   R1   R4   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR~      s    c      
   C  sƒ   t  | j t t f ƒ s4 t d d d d | d d ƒSt t g  t | j ƒ D]+ \ } } |  j | | j | d | ƒ ^ qJ Œ  ƒ Sd S(	   u'    Check all inline model admin classes. u   a list or tupleR3   u   inlinesR4   R   u
   admin.E103u   inlines[%d]N(	   R5   t   inlinesR7   R8   R9   R   R:   t   _check_inlines_itemR<   (   R1   R4   R=   t   item(    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR   )  s
    c         C  sØ   d j  | j | j g ƒ } d d l m } t | | ƒ s] t j d | d | j d d ƒg S| j	 s‰ t j d | d | j d d	 ƒg St | j	 t
 j ƒ s¾ t d
 d d | d | d d ƒS| | | j ƒ j ƒ  Sd S(   u    Check one inline model admin. u   .iÿÿÿÿ(   t   InlineModelAdminu*   '%s' must inherit from 'InlineModelAdmin'.R4   R   u
   admin.E104u#   '%s' must have a 'model' attribute.u
   admin.E105u   a ModelR3   u   %s.modelu
   admin.E106N(   t   joinRz   Rw   Rh   RŽ   RZ   R   R   RI   R<   R	   t   ModelR9   t
   admin_siteR   (   R1   R4   R<   t   inlineRE   t   inline_labelRŽ   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRŒ   4  s    
	
	
	
 c      
   C  sƒ   t  | j t t f ƒ s4 t d d d d | d d ƒSt t g  t | j ƒ D]+ \ } } |  j | | j | d | ƒ ^ qJ Œ  ƒ Sd S(	   uL    Check that list_display only contains fields or usable attributes.
        u   a list or tupleR3   u   list_displayR4   R   u
   admin.E107u   list_display[%d]N(	   R5   t   list_displayR7   R8   R9   R   R:   t   _check_list_display_itemR<   (   R1   R4   R=   R   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR€   O  s
    c         C  s†  t  | ƒ r g  St | | ƒ r# g  St | | ƒ ry | j j | ƒ } Wn> t k
 rˆ y t | | ƒ } Wq‰ t k
 r„ d  } q‰ Xn X| d  k rÙ t j	 d | | | j
 j | j j | j j f d | j
 d d ƒg St | t j ƒ rt j	 d | d | j
 d d ƒg Sg  Snm y | j j | ƒ WnR t k
 r}t j	 d | | | j
 j | j j | j j f d | j
 d d ƒg SXg  Sd  S(   Nuv   The value of '%s' refers to '%s', which is not a callable, an attribute of '%s', or an attribute or method on '%s.%s'.R4   R   u
   admin.E108u0   The value of '%s' must not be a ManyToManyField.u
   admin.E109(   Ri   RY   R@   RA   R   t   getattrt   AttributeErrorRG   R   R   RI   Rw   Rx   Ry   R5   R	   RS   (   R1   R4   R<   R   RE   R?   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR•   [  sB    (	

	
(	c      	   C  s¸   d d l  m } | j d
 k r# g  St | j t t f ƒ sW t d d d d | d d ƒS| j j	 | j j	 k r´ t t
 g  t | j ƒ D]% \ } } |  j | | d	 | ƒ ^ q… Œ  ƒ Sg  S(   uK    Check that list_display_links is a unique subset of list_display.
        iÿÿÿÿ(   t
   ModelAdminu   a list, a tuple, or NoneR3   u   list_display_linksR4   R   u
   admin.E110u   list_display_links[%d]N(   Rh   R˜   t   list_display_linksRG   R5   R7   R8   R9   t   get_list_displayt   __code__R   R:   t   _check_list_display_links_item(   R1   R4   R˜   R=   R>   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR   ’  s    <c         C  s@   | | j  k r8 t j d | | f d | j d d ƒg Sg  Sd  S(   NuI   The value of '%s' refers to '%s', which is not defined in 'list_display'.R4   R   u
   admin.E111(   R”   R   R   RI   (   R1   R4   R>   RE   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRœ   ¥  s    	
c      
   C  sƒ   t  | j t t f ƒ s4 t d d d d | d d ƒSt t g  t | j ƒ D]+ \ } } |  j | | j | d | ƒ ^ qJ Œ  ƒ Sd  S(   Nu   a list or tupleR3   u   list_filterR4   R   u
   admin.E112u   list_filter[%d](	   R5   t   list_filterR7   R8   R9   R   R:   t   _check_list_filter_itemR<   (   R1   R4   R=   R   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR‚   ³  s
    c   	   	   C  sU  d d l  m } m } t | ƒ rœ t | t j ƒ rœ t | | ƒ sc t d d d | d | d d ƒ St | | ƒ r• t	 j
 d	 | d | j d d
 ƒg Sg  Snµ t | t t f ƒ rö | \ } } t | | ƒ sï t d d d d | d | d d ƒ Sg  Sn[ | } y t | | ƒ Wn= t t f k
 rLt	 j
 d | | f d | j d d ƒg SXg  Sd S(   uG  
        Check one item of `list_filter`, i.e. check if it is one of three options:
        1. 'field' -- a basic field filter, possibly w/ relationships (e.g.
           'field__rel')
        2. ('field', SomeFieldListFilter) - a field-based list filter class
        3. SomeListFilter - a non-field list filter class
        iÿÿÿÿ(   t
   ListFiltert   FieldListFilterRX   u
   ListFilterR3   R4   R   u
   admin.E113u:   The value of '%s' must not inherit from 'FieldListFilter'.u
   admin.E114u   FieldListFilteru   %s[1]u
   admin.E115uB   The value of '%s' refers to '%s', which does not refer to a Field.u
   admin.E116N(   t   django.contrib.adminRŸ   R    Ri   R5   R	   t   FieldRZ   R\   R   R   RI   R8   R7   R   R   R   (	   R1   R4   R<   R   RE   RŸ   R    R?   t   list_filter_class(    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRž   ¼  s2    	
	
#	c         C  s?   t  | j t t t f ƒ s7 t d d d d | d d ƒSg  Sd S(   uA    Check that list_select_related is a boolean, a list or a tuple. u   a boolean, tuple or listR3   u   list_select_relatedR4   R   u
   admin.E117N(   R5   t   list_select_relatedRk   R7   R8   R9   (   R1   R4   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRƒ   ð  s    c         C  s6   t  | j t ƒ s. t d d d d | d d ƒSg  Sd S(   u)    Check that list_per_page is an integer. u
   an integerR3   u   list_per_pageR4   R   u
   admin.E118N(   R5   t   list_per_paget   intR9   (   R1   R4   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR„   ø  s    c         C  s6   t  | j t ƒ s. t d d d d | d d ƒSg  Sd S(   u-    Check that list_max_show_all is an integer. u
   an integerR3   u   list_max_show_allR4   R   u
   admin.E119N(   R5   t   list_max_show_allR¦   R9   (   R1   R4   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR…      s    c      
   C  sƒ   t  | j t t f ƒ s4 t d d d d | d d ƒSt t g  t | j ƒ D]+ \ } } |  j | | j | d | ƒ ^ qJ Œ  ƒ Sd S(	   ul    Check that list_editable is a sequence of editable fields from
        list_display without first element. u   a list or tupleR3   u   list_editableR4   R   u
   admin.E120u   list_editable[%d]N(	   R5   t   list_editableR7   R8   R9   R   R:   t   _check_list_editable_itemR<   (   R1   R4   R=   R   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR†     s
    c         C  sU  y | j  j | ƒ } Wn3 t k
 rK t d | d | d | d | d d ƒ SX| | j k r„ t j d | | f d | j d d ƒg S| j r¿ | | j k r¿ t j d	 | d | j d d
 ƒg S| j d | k r| j r| j d  k	 rt j d | | j d f d | j d d ƒg S| j
 sMt j d | | f d | j d d ƒg Sg  Sd  S(   NR?   R3   R<   R4   R   u
   admin.E121uK   The value of '%s' refers to '%s', which is not contained in 'list_display'.u
   admin.E122uM   The value of '%s' cannot be in both 'list_editable' and 'list_display_links'.u
   admin.E123i    u~   The value of '%s' refers to the first field in 'list_display' ('%s'), which cannot be used unless 'list_display_links' is set.u
   admin.E124uJ   The value of '%s' refers to '%s', which is not editable through the admin.u
   admin.E125(   R@   RA   R   RB   R”   R   R   RI   R™   RG   t   editable(   R1   R4   R<   R>   RE   R?   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR©     s:    &	

	
	
		
c         C  s<   t  | j t t f ƒ s4 t d d d d | d d ƒSg  Sd S(   u$    Check search_fields is a sequence. u   a list or tupleR3   u   search_fieldsR4   R   u
   admin.E126N(   R5   t   search_fieldsR7   R8   R9   (   R1   R4   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR‡   F  s    c         C  s¬   | j  d
 k r g  Sy t | j | j  ƒ d } Wn: t t f k
 rl t j d | j  d | j d d ƒg SXt	 | t
 j t
 j f ƒ s¤ t d d d d | d d	 ƒSg  Sd
 S(   uA    Check that date_hierarchy refers to DateField or DateTimeField. iÿÿÿÿuN   The value of 'date_hierarchy' refers to '%s', which does not refer to a Field.R4   R   u
   admin.E127u   a DateField or DateTimeFieldR3   u   date_hierarchyu
   admin.E128N(   t   date_hierarchyRG   R   R<   R   R   R   R   RI   R5   R	   t	   DateFieldRo   R9   (   R1   R4   R?   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRˆ   N  s    
	(   Rw   Rz   R   R}   R~   R   RŒ   R€   R•   R   Rœ   R‚   Rž   Rƒ   R„   R…   R†   R©   R‡   Rˆ   (    (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR{     s$   									7					4					2	t   InlineModelAdminChecksc           B  sG   e  Z d  „  Z d „  Z d „  Z d „  Z d „  Z d „  Z d „  Z RS(   c         K  s¯   t  t |  ƒ j | ƒ } | j } | j |  j | | ƒ ƒ | j |  j | | ƒ ƒ | j |  j | ƒ ƒ | j |  j | ƒ ƒ | j |  j	 | ƒ ƒ | j |  j
 | ƒ ƒ | S(   N(   R|   R®   R   t   parent_modelR   t   _check_relationt   _check_exclude_of_parent_modelt   _check_extrat   _check_max_numt   _check_min_numt   _check_formset(   R1   t
   inline_objR   R   R¯   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR   h  s    	c         C  s»   t  t |  ƒ j | ƒ } | r" g  S|  j | | ƒ r8 g  S| j d  k rK g  St | | j d | j ƒ} | j	 | j k r³ t
 j d | j	 | j j | j j f d | j d d ƒg Sg  Sd  S(   Nt   fk_nameuY   Cannot exclude the field '%s', because it is the foreign key to the parent model '%s.%s'.R4   R   u
   admin.E201(   R|   R®   R(   R°   RW   RG   R   R<   R·   t   nameR   R   R@   Rx   Ry   RI   (   R1   R4   R¯   R   t   fk(    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR±   s  s    	
c         C  s^   y t  | | j d | j ƒWn6 t k
 rU } t j | j d d | j d d ƒg SXg  Sd  S(   NR·   i    R4   R   u
   admin.E202(   R   R<   R·   t
   ValueErrorR   R   t   argsRI   (   R1   R4   R¯   t   e(    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR°     s
    'c         C  s6   t  | j t ƒ s. t d d d d | d d ƒSg  Sd S(   u!    Check that extra is an integer. u
   an integerR3   u   extraR4   R   u
   admin.E203N(   R5   t   extraR¦   R9   (   R1   R4   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR²   ˜  s    c         C  sI   | j  d k r g  St | j  t ƒ sA t d d d d | d d ƒSg  Sd S(   u#    Check that max_num is an integer. u
   an integerR3   u   max_numR4   R   u
   admin.E204N(   t   max_numRG   R5   R¦   R9   (   R1   R4   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR³      s
    c         C  sI   | j  d k r g  St | j  t ƒ sA t d d d d | d d ƒSg  Sd S(   u#    Check that min_num is an integer. u
   an integerR3   u   min_numR4   R   u
   admin.E205N(   t   min_numRG   R5   R¦   R9   (   R1   R4   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR´   ª  s
    c      	   C  s9   t  | j t ƒ s1 t d d d d d | d d ƒ Sg  Sd S(	   u2    Check formset is a subclass of BaseModelFormSet. RX   u   BaseModelFormSetR3   u   formsetR4   R   u
   admin.E206N(   RZ   t   formsetR   R\   (   R1   R4   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRµ   ´  s    (	   Rw   Rz   R   R±   R°   R²   R³   R´   Rµ   (    (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR®   f  s   					
	
c         C  s)   t  j d | |  f d | j d | ƒg S(   Nu   The value of '%s' must be %s.R4   R   (   R   R   RI   (   t   typeR3   R4   R   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR9   ½  s    	c         C  s)   t  j d | |  f d | j d | ƒg S(   Nu)   The value of '%s' must inherit from '%s'.R4   R   (   R   R   RI   (   RX   R3   R4   R   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyR\   Ç  s    	c         C  s;   t  j d | |  | j j | j j f d | j d | ƒg S(   NuG   The value of '%s' refers to '%s', which is not an attribute of '%s.%s'.R4   R   (   R   R   R@   Rx   Ry   RI   (   R?   R3   R<   R4   R   (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyRB   Ñ  s
    	N(#   t
   __future__R    t	   itertoolsR   t   django.appsR   t   django.confR   t   django.contrib.admin.utilsR   R   R   t   django.coreR   t   django.core.exceptionsR   t	   django.dbR	   t   django.db.models.constantsR
   t   django.forms.modelsR   R   R   t   django.template.engineR   R   R#   t   objectR$   R{   R®   R9   R\   RB   (    (    (    s=   /tmp/pip-unpacked-wheel-BAJOf3/django/contrib/admin/checks.pyt   <module>   s(   		'ÿ Âÿ bW	
	
