ó
r±E^c           @  s<  d  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
 m Z d d l m Z m Z d d l m Z m Z d d l m Z 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  m! Z! d d l" m# Z# m$ Z% d d d d d d d d d d d d f Z& d Z' e( e( d „ Z) e( e( d „ Z* d „  Z+ e( e( e( e( e( e( e( e( e( e, d „
 Z- d  e. f d! „  ƒ  YZ/ d" e f d# „  ƒ  YZ0 d$ e f d% „  ƒ  YZ1 d& e j2 e0 e1 ƒ f d' „  ƒ  YZ3 e3 e( e( e( e( e( e( e( e( e( d( „
 Z4 d) e f d* „  ƒ  YZ5 e3 e( e5 d+ e6 e6 e( e( e( e( e6 e( e( e( e( e( e6 e( d, „ Z7 d- e5 f d. „  ƒ  YZ8 e( e6 d/ „ Z9 e3 e8 e( e( e( d0 e6 e, e( e( e( e6 e( e( e( e( e( e6 e( d1 „ Z: d2 e f d3 „  ƒ  YZ; d4 e. f d5 „  ƒ  YZ< d6 e f d7 „  ƒ  YZ= d8 e= f d9 „  ƒ  YZ> d: „  Z? d; S(<   u[   
Helper functions for creating Form classes from Django models
and database field objects.
iÿÿÿÿ(   t   unicode_literals(   t   OrderedDict(   t   chain(   t   NON_FIELD_ERRORSt
   FieldErrort   ImproperlyConfiguredt   ValidationError(   t   ChoiceFieldt   Field(   t   BaseFormt   DeclarativeFieldsMetaclass(   t   BaseFormSett   formset_factory(   t	   ErrorList(   t   HiddenInputt   MultipleHiddenInputt   SelectMultiple(   t   six(   t
   force_text(   t   capfirstt   get_text_list(   t   ugettextt   ugettext_lazyu	   ModelFormu   BaseModelFormu   model_to_dictu   fields_for_modelu   ModelChoiceFieldu   ModelMultipleChoiceFieldu
   ALL_FIELDSu   BaseModelFormSetu   modelformset_factoryu   BaseInlineFormSetu   inlineformset_factoryu   modelform_factoryu   __all__c   	      C  sT  d d l  m } | j } |  j } g  } xý | j D]ò } | j s2 t | | j ƒ s2 | j | k ri q2 n  | d k	 rŠ | j | k rŠ q2 n  | r¥ | j | k r¥ q2 n  | j
 ƒ  rë |  | j j j j |  j |  j |  j | j ƒ ƒ rë q2 n  t | | j ƒ r| j | ƒ q2 | j | | | j ƒ q2 Wx% | D] } | j | | | j ƒ q/W| S(   už   
    Constructs and returns a model instance from the bound ``form``'s
    ``cleaned_data``, but does not save the returned instance to the
    database.
    iÿÿÿÿ(   t   modelsN(   t	   django.dbR   t   _metat   cleaned_datat   fieldst   editablet
   isinstancet	   AutoFieldt   namet   Nonet   has_defaultt   fieldt   widgett   value_omitted_from_datat   datat   filest
   add_prefixt	   FileFieldt   appendt   save_form_data(	   t   formt   instanceR   t   excludeR   t   optsR   t   file_field_listt   f(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   construct_instance$   s*    		4c         C  sÜ   d d l  m } |  j } i  } x¶ t | j | j | j ƒ D]™ } t | d t ƒ sY q; n  | rt | j	 | k rt q; n  | r� | j	 | k r� q; n  | j
 |  ƒ | | j	 <t | | j ƒ r; t | | j	 ƒ | | j	 <q; q; W| S(   u¹  
    Returns a dict containing the data in ``instance`` suitable for passing as
    a Form's ``initial`` keyword argument.

    ``fields`` is an optional list of field names. If provided, only the named
    fields will be included in the returned dict.

    ``exclude`` is an optional list of field names. If provided, the named
    fields will be excluded from the returned dict, even if they are listed in
    the ``fields`` argument.
    iÿÿÿÿ(   R   u   editable(   R   R   R   R   t   concrete_fieldst   private_fieldst   many_to_manyt   getattrt   FalseR   t   value_from_objectR   t   ManyToManyFieldt   list(   R,   R   R-   R   R.   R%   R0   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   model_to_dictK   s    	"!c         C  sU   t  |  d ƒ rQ t  |  d ƒ rQ |  j ƒ  } | d k	 rQ |  j j | ƒ |  _ qQ n  d S(   u=   Apply limit_choices_to to the formfield's queryset if needed.u   querysetu   get_limit_choices_toN(   t   hasattrt   get_limit_choices_toR    t   querysett   complex_filter(   t	   formfieldt   limit_choices_to(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt#   apply_limit_choices_to_to_formfieldi   s    c         C  s  g  } g  } |  j  } d d l m } g  | j D] } t | | ƒ r/ | ^ q/ } xZt t | j | | j ƒ ƒ D]:} t	 | d t
 ƒ sâ | d k	 ro | j | k ro | d k s½ | j | k ro t d | j |  j f ƒ ‚ qo qo n  | d k	 r| j | k rqo n  | r| j | k rqo n  i  } | rM| j | k rM| | j | d <n  | t k sn| r{| j | k r{t | d <n  | r¤| j | k r¤| | j | d <n  | rÍ| j | k rÍ| | j | d <n  | rö| j | k rö| | j | d	 <n  |	 r| j |	 k r|	 | j | d
 <n  | d k r=| j | �  } n* t | ƒ sXt d ƒ ‚ n | | | � } | r™|
 r€t | ƒ n  | j | j | f ƒ qo | j | j ƒ qo Wt | ƒ } | rt g  | D]@ } | sè| rÉ| | k rÉ| | k rÉ| | j | ƒ f ^ qÉƒ } n  | S(   ud  
    Returns a ``OrderedDict`` containing form fields for the given model.

    ``fields`` is an optional list of field names. If provided, only the named
    fields will be included in the returned fields.

    ``exclude`` is an optional list of field names. If provided, the named
    fields will be excluded from the returned fields, even if they are listed
    in the ``fields`` argument.

    ``widgets`` is a dictionary of model field names mapped to a widget.

    ``formfield_callback`` is a callable that takes a model field and returns
    a form field.

    ``localized_fields`` is a list of names of fields which should be localized.

    ``labels`` is a dictionary of model field names mapped to a label.

    ``help_texts`` is a dictionary of model field names mapped to a help text.

    ``error_messages`` is a dictionary of model field names mapped to a
    dictionary of error messages.

    ``field_classes`` is a dictionary of model field names mapped to a form
    field class.

    ``apply_limit_choices_to`` is a boolean indicating if limit_choices_to
    should be applied to a field's queryset.
    iÿÿÿÿ(   R   u   editableuH   '%s' cannot be specified for %s model form as it is a non-editable fieldu   widgetu   localizeu   labelu	   help_textu   error_messagesu
   form_classu1   formfield_callback must be a function or callableN(   R   t   django.db.models.fieldsR   R3   R   t   sortedR   R2   R4   R5   R6   R    R   R   t   __name__t
   ALL_FIELDSt   TrueR?   t   callablet	   TypeErrorRA   R)   R   t   get(   t   modelR   R-   t   widgetst   formfield_callbackt   localized_fieldst   labelst
   help_textst   error_messagest   field_classest   apply_limit_choices_tot
   field_listt   ignoredR.   t
   ModelFieldR0   t   sortable_private_fieldst   kwargsR?   t
   field_dict(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   fields_for_modelq   s\    "	+%!Ft   ModelFormOptionsc           B  s   e  Z d d  „ Z RS(   c         C  sÁ   t  | d d  ƒ |  _ t  | d d  ƒ |  _ t  | d d  ƒ |  _ t  | d d  ƒ |  _ t  | d d  ƒ |  _ t  | d d  ƒ |  _ t  | d d  ƒ |  _ t  | d d  ƒ |  _	 t  | d	 d  ƒ |  _
 d  S(
   Nu   modelu   fieldsu   excludeu   widgetsu   localized_fieldsu   labelsu
   help_textsu   error_messagesu   field_classes(   R5   R    RJ   R   R-   RK   RM   RN   RO   RP   RQ   (   t   selft   options(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   __init__Ì   s    N(   RD   t
   __module__R    R]   (    (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRZ   Ë   s   t   ModelFormMetaclassc           B  s   e  Z d  „  Z RS(   c         C  sr  d  } x? | D]7 } t | d ƒ r t | j d ƒ r | j j } Pq q W| j d | ƒ } t t |  ƒ j |  | | | ƒ } | t f k rŽ | St	 t
 | d d  ƒ ƒ } | _ xu d d d g D]d }	 t
 | |	 ƒ }
 t |
 t j ƒ r½ |
 t k r½ d i | j d 6|	 d 6|
 d	 6} t | ƒ ‚ q½ q½ W| j r\| j d  k r_| j d  k r_t d
 | ƒ ‚ n  | j t k rzd  | _ n  t | j | j | j | j | | j | j | j | j | j d t ƒ
} g  t j | ƒ D] \ } } | sÒ| ^ qÒ} t | ƒ t | j  j! ƒ  ƒ } | rId } | d j" | ƒ | j j f } t# | ƒ ‚ n  | j$ | j  ƒ n	 | j  } | | _% | S(   Nu   Metau   formfield_callbacku   fieldsu   excludeu   localized_fieldsuP   %(model)s.Meta.%(opt)s cannot be a string. Did you mean to type: ('%(value)s',)?u   modelu   optu   valueu|   Creating a ModelForm without either the 'fields' attribute or the 'exclude' attribute is prohibited; form %s needs updating.RR   u&   Unknown field(s) (%s) specified for %su   , (&   R    R;   t   MetaRL   t   popt   superR_   t   __new__t   BaseModelFormRZ   R5   R   R   R   t   string_typesRE   RD   RH   RJ   R   R-   R   RY   RK   RM   RN   RO   RP   RQ   R6   t	   iteritemst   sett   declared_fieldst   keyst   joinR   t   updatet   base_fields(   t   mcsR   t   basest   attrst   base_formfield_callbackt   bRL   t	   new_classR.   t   optt   valuet   msgR   t   kt   vt   none_model_fieldst   missing_fieldst   message(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRc   Ù   sV    !!
		.			(   RD   R^   Rc   (    (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR_   Ø   s   Rd   c           B  sz   e  Z d	 d	 d  d	 d	 e d	 e d	 d	 d „
 Z d „  Z d „  Z d „  Z d „  Z	 d „  Z
 d „  Z e d „ Z e e _ RS(
   u   id_%sc         C  sê   |  j  } | j d  k r' t d ƒ ‚ n  |	 d  k rK | j ƒ  |  _ i  } n! |	 |  _ t |	 | j | j ƒ } | d  k	 rˆ | j | ƒ n  t	 |  _
 t t |  ƒ j | | | | | | | | d |
 ƒx! |  j j ƒ  D] } t | ƒ qÒ Wd  S(   Nu'   ModelForm has no model class specified.t   use_required_attribute(   R   RJ   R    t
   ValueErrorR,   R:   R   R-   Rk   R6   t   _validate_uniqueRb   Rd   R]   t   valuesRA   (   R[   R%   R&   t   auto_idt   prefixt   initialt   error_classt   label_suffixt   empty_permittedR,   R{   R.   t   object_dataR?   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR]   "  s     				c         C  s.  g  } x!|  j  j j D]} | j } | |  j k rG | j | j ƒ q |  j j rx | |  j j k rx | j | j ƒ q |  j j r© | |  j j k r© | j | j ƒ q | |  j j ƒ  k rÑ | j | j ƒ q |  j | } |  j j	 | ƒ } | j
 r | j r | | j k r | j | j ƒ q q W| S(   u¿   
        For backwards-compatibility, several types of fields need to be
        excluded from model validation. See the following tickets for
        details: #12507, #12521, #12553
        (   R,   R   R   R   R)   R-   t   _errorsRi   R   RI   t   blankt   requiredt   empty_values(   R[   R-   R0   R"   t
   form_fieldt   field_value(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   _get_validation_exclusions=  s     		#c         C  s   t  |  _ |  j S(   N(   RF   R}   R   (   R[   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   cleang  s    	c         C  sý   |  j  } t | d ƒ r$ | j } n i | t 6} xµ | j ƒ  D]§ \ } } | t k r~ | j r~ t | j k r~ | j t } n% | |  j k r> |  j | j } n q> x? | D]7 } t | t ƒ rª | j	 | k rª | | j	 | _
 qª qª Wq> W|  j d  | ƒ d  S(   Nu
   error_dict(   R   R;   t
   error_dictR   t   itemsRP   R   R   R   t   codeRz   t	   add_errorR    (   R[   t   errorsR.   RŽ   R"   t   messagesRP   Rz   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   _update_errorsk  s     	c         C  sö   |  j  } |  j ƒ  } x< |  j j ƒ  D]+ \ } } t | t ƒ r% | j | ƒ q% q% Wy% t |  |  j | j | j	 ƒ |  _ Wn  t
 k
 r› } |  j | ƒ n Xy |  j j d | d t ƒ Wn  t
 k
 rÛ } |  j | ƒ n X|  j rò |  j ƒ  n  d  S(   NR-   t   validate_unique(   R   RŒ   R   R�   R   t   InlineForeignKeyFieldR)   R1   R,   R-   R   R”   t
   full_cleanR6   R}   R•   (   R[   R.   R-   R   R"   t   e(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   _post_clean‡  s    		%	c         C  sJ   |  j  ƒ  } y |  j j d | ƒ Wn  t k
 rE } |  j | ƒ n Xd S(   u„   
        Calls the instance's validate_unique() method and updates the form's
        validation errors if any were raised.
        R-   N(   RŒ   R,   R•   R   R”   (   R[   R-   R˜   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR•   ¥  s
    c         C  sÈ   |  j  } |  j j } |  j j } |  j j } x” t | j | j ƒ D]} } t | d ƒ s^ qC n  | ry | j	 | k ry qC n  | r” | j	 | k r” qC n  | j	 | k rC | j
 |  j | | j	 ƒ qC qC Wd S(   uS   
        Save the many-to-many fields and generic relations for this form.
        u   save_form_dataN(   R   R   R-   R   R,   R   R4   R3   R;   R   R*   (   R[   R   R-   R   R.   R0   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt	   _save_m2m°  s    	c         C  ss   |  j  r@ t d |  j j j |  j j j r0 d n d f ƒ ‚ n  | r` |  j j ƒ  |  j ƒ  n |  j |  _	 |  j S(   uë   
        Save this form's self.instance object if commit=True. Otherwise, add
        a save_m2m() method to the form which can be called after the instance
        is saved manually at a later time. Return the model instance.
        u8   The %s could not be %s because the data didn't validate.u   createdu   changed(
   R’   R|   R,   R   t   object_namet   _statet   addingt   saveRš   t   save_m2m(   R[   t   commit(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRž   Å  s    	%N(   RD   R^   R    R   R6   R]   RŒ   R�   R”   R™   R•   Rš   RF   Rž   t   alters_data(    (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRd   !  s   		*					t	   ModelFormc           B  s   e  Z RS(    (   RD   R^   (    (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR¢   ß  s   c         C  s®  i |  d 6} | d k	 r& | | d <n  | d k	 r? | | d <n  | d k	 rX | | d <n  | d k	 rq | | d <n  | d k	 rŠ | | d <n  | d k	 r£ | | d <n  |	 d k	 r¼ |	 | d <n  |
 d k	 rÕ |
 | d	 <n  t f } t | d
 ƒ rÿ | j t f } n  t t d
 ƒ | | ƒ } | r/t | ƒ | _ n  |  j t d ƒ } i | d
 6| d 6} t	 | d d ƒ d k r•t	 | d d ƒ d k r•t
 d ƒ ‚ n  t | ƒ | | f | ƒ S(   u  
    Returns a ModelForm containing form fields for the given model.

    ``fields`` is an optional list of field names. If provided, only the named
    fields will be included in the returned fields. If omitted or '__all__',
    all fields will be used.

    ``exclude`` is an optional list of field names. If provided, the named
    fields will be excluded from the returned fields, even if they are listed
    in the ``fields`` argument.

    ``widgets`` is a dictionary of model field names mapped to a widget.

    ``localized_fields`` is a list of names of fields which should be localized.

    ``formfield_callback`` is a callable that takes a model field and returns
    a form field.

    ``labels`` is a dictionary of model field names mapped to a label.

    ``help_texts`` is a dictionary of model field names mapped to a help text.

    ``error_messages`` is a dictionary of model field names mapped to a
    dictionary of error messages.

    ``field_classes`` is a dictionary of model field names mapped to a form
    field class.
    u   modelu   fieldsu   excludeu   widgetsu   localized_fieldsu   labelsu
   help_textsu   error_messagesu   field_classesu   Metau   Formu   formfield_callbackuZ   Calling modelform_factory without defining 'fields' or 'exclude' explicitly is prohibited.N(   R    t   objectR;   R`   t   typet   strt   staticmethodRL   RD   R5   R   (   RJ   R+   R   R-   RL   RK   RM   RN   RO   RP   RQ   Ro   t   parentR`   t
   class_namet   form_class_attrs(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   modelform_factoryã  s@    %	
t   BaseModelFormSetc           B  sé   e  Z d  Z d Z e ƒ  Z d d d d d d „ Z d „  Z d „  Z	 d „  Z
 d „  Z d „  Z e d „ Z e d	 „ Z e d
 „ Z e d „ Z e e _ d „  Z d „  Z d „  Z d „  Z d „  Z e d „ Z e d „ Z d „  Z RS(   uO   
    A ``FormSet`` for editing a queryset and/or adding new objects to it.
    u   id_%sc         K  sg   | |  _  | j d d  ƒ |  _ i | d 6| d 6| d 6| d 6} | j | ƒ t t |  ƒ j | �  d  S(   Nu   initialu   datau   filesu   auto_idu   prefix(   R=   Ra   R    t   initial_extraRk   Rb   R«   R]   (   R[   R%   R&   R   R€   R=   RW   t   defaults(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR]   A  s
    	"c         C  s5   |  j  p |  j s" t |  j ƒ  ƒ St t |  ƒ j ƒ  S(   u>   Returns the number of forms that are required in this FormSet.(   R%   R&   t   lent   get_querysetRb   R«   t   initial_form_count(   R[   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR°   I  s    c         C  s;   t  |  d ƒ s+ d „  |  j ƒ  Dƒ |  _ n  |  j j | ƒ S(   Nu   _object_dictc         S  s   i  |  ] } | | j  “ q S(    (   t   pk(   t   .0t   o(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pys
   <dictcomp>Q  s   	 (   R;   R¯   t   _object_dictRI   (   R[   R±   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   _existing_objectO  s    c         C  s,   x" | j  d k	 r$ | j  j ƒ  } q W| j S(   u‹   
        If the field is a related field, fetch the concrete field's (that
        is, the ultimate pointed-to field's) to_python.
        N(   t   remote_fieldR    t   get_related_fieldt	   to_python(   R[   R"   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   _get_to_pythonT  s    c         K  s,  |  j  r� | |  j ƒ  k  r� d |  j | ƒ |  j j j j f } |  j | } |  j j j } |  j | ƒ } | | ƒ } |  j	 | ƒ | d <n  | |  j ƒ  k  rÂ d | k rÂ |  j
 ƒ  | | d <n  | |  j ƒ  k r|  j ry |  j | |  j ƒ  | d <Wqt k
 rqXn  t t |  ƒ j | | � S(   Nu   %s-%su   instanceu   initial(   t   is_boundR°   R'   RJ   R   R±   R   R%   R¹   Rµ   R¯   R¬   t
   IndexErrorRb   R«   t   _construct_form(   R[   t   iRW   t   pk_keyR±   t   pk_fieldR¸   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR¼   ]  s    %c         C  sv   t  |  d ƒ so |  j d  k	 r* |  j } n |  j j j ƒ  } | j sc | j |  j j j	 j
 ƒ } n  | |  _ n  |  j S(   Nu	   _queryset(   R;   R=   R    RJ   t   _default_managerR¯   t   orderedt   order_byR   R±   R   t	   _queryset(   R[   t   qs(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR¯   o  s    	c         C  s   | j  d | ƒ S(   u:   Saves and returns a new model instance for the given form.R    (   Rž   (   R[   R+   R    (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   save_new‚  s    c         C  s   | j  d | ƒ S(   u@   Saves and returns an existing model instance for the given form.R    (   Rž   (   R[   R+   R,   R    (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   save_existing†  s    c         C  s   | r | j  ƒ  n  d S(   u#   Deletes an existing model instance.N(   t   delete(   R[   t   objR    (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   delete_existingŠ  s    c           sD   | s* g  ˆ  _  ‡  f d †  } | ˆ  _ n  ˆ  j | ƒ ˆ  j | ƒ S(   u…   Saves model instances for every form, adding and changing instances
        as necessary, and returns the list of instances.
        c            s"   x ˆ  j  D] }  |  j ƒ  q
 Wd  S(   N(   t   saved_formsRŸ   (   R+   (   R[   (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRŸ   –  s    (   RÊ   RŸ   t   save_existing_objectst   save_new_objects(   R[   R    RŸ   (    (   R[   s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRž   �  s
    	c         C  s   |  j  ƒ  d  S(   N(   R•   (   R[   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR�   ž  s    c           sî  t  ƒ  } t  ƒ  } ˆ j } g  ˆ j D]$ ‰  ˆ  j ƒ  r% ˆ  | k r% ˆ  ^ q% } x_ | D]W ‰  ˆ  j ƒ  } ˆ  j j d | ƒ \ } } | j t  | ƒ ƒ } | j t  | ƒ ƒ } qV Wg  } xð | D]è \ }	 }
 t  ƒ  } xÐ | D]È ‰  ‡  ‡ f d †  |
 Dƒ } t d „  | Dƒ ƒ } | rÚ d  | k rÚ | | k r’| j
 ˆ j |
 ƒ ƒ ˆ j ˆ j ƒ  g ƒ ˆ  j t <x- |
 D]" } | ˆ  j k riˆ  j | =qiqiWn  | j | ƒ qÚ qÚ Wq¾ Wx(| D] } t  ƒ  } | \ }	 } } } xü | D]ô ‰  ˆ  j rÙˆ  j | d  k	 rÙˆ  j | d  k	 rÙ| d k rBˆ  j | } | j | j | j f } n t ˆ  j | | ƒ f } ˆ  j | f | } | | k r½| j
 ˆ j | ƒ ƒ ˆ j ˆ j ƒ  g ƒ ˆ  j t <ˆ  j | =n  | j | ƒ qÙqÙWq±W| rêt | ƒ ‚ n  d  S(   NR-   c         3  s@   |  ]6 } | ˆ  j  k r | ˆ j k r- | n
 ˆ  j  | Vq d  S(   N(   R   t   unique_fields(   R²   R"   (   R+   R[   (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pys	   <genexpr>´  s   c         s  s0   |  ]& } t  | d  ƒ r$ | j ƒ  n | Vq d S(   u   _get_pk_valN(   R;   t   _get_pk_val(   R²   t   d(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pys	   <genexpr>¸  s   u   date(   Rg   t   deleted_formst   formst   is_validRŒ   R,   t   _get_unique_checkst   uniont   tupleR    R)   t   get_unique_error_messageR‚   t   get_form_errorR†   R   R   t   addt   yeart   montht   dayR5   t   get_date_error_messageR   (   R[   t   all_unique_checkst   all_date_checkst   forms_to_deletet   valid_formsR-   t   unique_checkst   date_checksR’   t   uclasst   unique_checkt	   seen_datat   row_dataR"   t
   date_checkt   lookupt
   unique_fort   datet	   date_dataR%   (    (   R+   R[   s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR•   ¡  sV    			4	
		c         C  s\   t  | ƒ d k r+ t d ƒ i | d d 6St d ƒ i t | t j t d ƒ ƒ ƒ d 6Sd  S(   Ni   u0   Please correct the duplicate data for %(field)s.i    u   fielduF   Please correct the duplicate data for %(field)s, which must be unique.u   and(   R®   R   R   R   t	   text_typet   _(   R[   Rä   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRÖ   æ  s
    c         C  s8   t  d ƒ i | d d 6| d d 6t j | d ƒ d 6S(   Nuo   Please correct the duplicate data for %(field_name)s which must be unique for the %(lookup)s in %(date_field)s.i   u
   field_namei   u
   date_fieldi   u   lookup(   R   R   Rì   (   R[   Rç   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRÜ   ð  s    c         C  s
   t  d ƒ S(   Nu*   Please correct the duplicate values below.(   R   (   R[   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR×   ú  s    c         C  sö   g  |  _  g  |  _ |  j s g  Sg  } |  j } xÁ |  j D]¶ } | j } | j d  k r\ q8 n  | | k rŽ |  j j | ƒ |  j | d | ƒq8 | j	 ƒ  r8 |  j  j | | j
 f ƒ | j |  j | | d | ƒƒ | sî |  j j | ƒ qî q8 q8 W| S(   NR    (   t   changed_objectst   deleted_objectst   initial_formsRÐ   R,   R±   R    R)   RÉ   t   has_changedt   changed_dataRÆ   RÊ   (   R[   R    t   saved_instancesRß   R+   RÈ   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRË   ý  s&    					c         C  sŒ   g  |  _  xy |  j D]n } | j ƒ  s+ q n  |  j rI |  j | ƒ rI q n  |  j  j |  j | d | ƒƒ | s |  j j | ƒ q q W|  j  S(   NR    (   t   new_objectst   extra_formsRñ   t
   can_deletet   _should_delete_formR)   RÅ   RÊ   (   R[   R    R+   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRÌ     s    	c   	        s³  d d l  m ‰  m } m } |  j j j |  _ } ‡  ‡ f d †  ‰ ˆ | ƒ sb | j | j	 k r–| j
 r� | j j j r€ d n	 | j j } nF y, | d k	 r´ |  j ƒ  | j } n d } Wn t k
 rÔ d } n Xt | | ƒ só t | | ƒ r| j j j j ƒ  } n |  j j j ƒ  } | j | j j j ƒ } | j j rb| j j j |  j j t ƒ } n t } t | d | d t d | ƒ| j	 |  j j <n  t t |  ƒ j | | ƒ d S(   u0   Add a hidden field for the object's primary key.iÿÿÿÿ(   R   t   OneToOneFieldt
   ForeignKeyc           sM   |  j  pL |  j pL t |  ˆ  ƒ pL |  j oL |  j j oL ˆ |  j j j j ƒ S(   N(   R   t   auto_createdR   R¶   t   parent_linkRJ   R   R±   (   R±   (   R   t   pk_is_not_editable(    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRü   /  s    "R�   Rˆ   R#   N(   t   django.db.modelsR   Rø   Rù   RJ   R   R±   t	   _pk_fieldR   R   Rº   R,   Rœ   R�   R    R¯   R»   R   R¶   RÀ   t   usingt   dbRK   RI   R   t   ModelChoiceFieldR6   Rb   R«   t
   add_fields(	   R[   R+   t   indexRø   Rù   R±   t   pk_valueRÄ   R#   (    (   R   Rü   s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR  %  s*    	$

!.N(   RD   R^   t   __doc__R    RJ   Rg   RÍ   R]   R°   Rµ   R¹   R¼   R¯   RF   RÅ   RÆ   RÉ   Rž   R¡   R�   R•   RÖ   RÜ   R×   RË   RÌ   R  (    (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR«   8  s.   										E	
	
	i   c         C  sß   t  | d d ƒ } t  | d | ƒ d k rQ t  | d |	 ƒ d k rQ t d ƒ ‚ n  t |  d | d | d |	 d | d	 |
 d
 | d | d | d | d | ƒ
} t | | d | d | d | d | d | d | d | ƒ} |  | _ | S(   uC   
    Returns a FormSet class for the given Django model class.
    u   Metau   fieldsu   excludeu]   Calling modelformset_factory without defining 'fields' or 'exclude' explicitly is prohibited.R+   R   R-   RL   RK   RM   RN   RO   RP   RQ   t   extrat   min_numt   max_numt	   can_orderRö   t   validate_mint   validate_maxN(   R5   R    R   Rª   R   RJ   (   RJ   R+   RL   t   formsetR  Rö   R	  R  R   R-   RK   R  RM   RN   RO   RP   R  R
  RQ   t   metat   FormSet(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   modelformset_factoryQ  s    		t   BaseInlineFormSetc           B  sh   e  Z d  Z d d d e d d d „ Z d „  Z d „  Z e d „  ƒ Z	 e
 d „ Z d „  Z d „  Z RS(	   u0   A formset for child objects related to a parent.c   	      K  sQ  | d  k r$ |  j j j ƒ  |  _ n	 | |  _ | |  _ | d  k rQ |  j j } n  |  j j d  k	 r… | j i |  j |  j j	 6�  } n | j
 ƒ  } |  j j	 h |  _ t t |  ƒ j | | d | d | | �|  j j j rM|  j j	 |  j j j k rMt |  j j j t ƒ r.t |  j j j ƒ |  j j _ n  |  j j j j |  j j	 ƒ n  d  S(   NR€   R=   (   R    t   fkR¶   RJ   R,   t   save_as_newRÀ   R±   t   filterR   t   noneRÍ   Rb   R  R]   R+   R   R   R   RÕ   R9   R)   (	   R[   R%   R&   R,   R  R€   R=   RW   RÄ   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR]   r  s     		"
*!c         C  s    |  j  r d St t |  ƒ j ƒ  S(   Ni    (   R  Rb   R  R°   (   R[   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR°   Š  s    	c         K  s-  t  t |  ƒ j | | � } |  j rª t | j d d  ƒ } | d  k	 rT t | j _ n  d  | j | j	 |  j
 j ƒ <d  | j | j	 |  j j ƒ <| d  k	 rª | | j _ qª n  |  j j } |  j j j |  j j j j j j k rt |  j |  j j j ƒ } t | d | ƒ } n  t | j |  j j ƒ  | ƒ | S(   Nu   _mutableu   pk(   Rb   R  R¼   R  R5   R%   R    RF   t   _mutableR'   Rþ   R   R  R,   R±   R¶   t
   field_nameRJ   R   t   setattrt   get_attname(   R[   R½   RW   R+   t   mutablet   fk_value(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR¼   �  s    	'c         C  s%   |  j  j j d |  j ƒ j d d ƒ S(   NRJ   u   +u    (   R  R¶   t   get_accessor_nameRJ   t   replace(   t   cls(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   get_default_prefix¦  s    c         C  s§   t  | j |  j j |  j ƒ | j d t ƒ } t |  j |  j j j ƒ } t  | |  j j	 ƒ  t | d | ƒ ƒ | r� | j ƒ  n  | r£ t
 | d ƒ r£ | j ƒ  n  | S(   NR    u   pku   save_m2m(   R  R,   R  R   Rž   R6   R5   R¶   R  R  R;   RŸ   (   R[   R+   R    RÈ   R  (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRÅ   ª  s    %c         C  sU  t  t |  ƒ j | | ƒ |  j |  j k rG |  j j } i t d 6} nz |  j j } i t | j j	 | ƒ d t
 |  j j ƒ ƒ d 6} |  j j j |  j j j j j j k rÁ |  j j j | d <n  |  j j j r8| j	 d ƒ d  k	 r|  j j j | d ƒ } n |  j j j } | j ƒ  r8t |  j | j d  ƒ q8n  t |  j | � | j | <d  S(   Nu   pk_fieldu   labelu   to_field(   Rb   R  R  Rþ   R  R   RF   R5   R   RI   R   t   verbose_nameR¶   R  RJ   R   R±   R,   Rœ   R�   R    t	   get_fieldR!   R  t   attnameR–   (   R[   R+   R  R   RW   t   to_field(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR  »  s     .'c         C  sA   g  | D] } | |  j  j k r | ^ q } t t |  ƒ j | ƒ S(   N(   R  R   Rb   R  RÖ   (   R[   Rä   R"   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRÖ   Ö  s    +N(   RD   R^   R  R    R6   R]   R°   R¼   t   classmethodR  RF   RÅ   R  RÖ   (    (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR  p  s   				c   	      C  s×  d d l  m } | j } | rù g  | j D] } | j | k r) | ^ q) } t | ƒ d k rÅ | d } t | | ƒ s£ | j j |  k rö | j j |  j j	 ƒ  k rö t
 d | |  j j f ƒ ‚ qö qÓt | ƒ d k rÓt
 d | j j | f ƒ ‚ qÓnÚ g  | j D]H } t | | ƒ r| j j |  k sE| j j |  j j	 ƒ  k r| ^ q} t | ƒ d k rp| d } nc t | ƒ d k r±| rŒd St
 d | j j |  j j f ƒ ‚ n" t
 d	 | j j |  j j f ƒ ‚ | S(
   uI  
    Finds and returns the ForeignKey from model to parent if there is one
    (returns None if can_fail is True and no such field exists). If fk_name is
    provided, assume it is the name of the ForeignKey field. Unless can_fail is
    True, an exception is raised if there is no ForeignKey from model to
    parent_model.
    iÿÿÿÿ(   Rù   i   i    u)   fk_name '%s' is not a ForeignKey to '%s'.u   '%s' has no field named '%s'.Nu   '%s' has no ForeignKey to '%s'.u*   '%s' has more than one ForeignKey to '%s'.(   Rý   Rù   R   R   R   R®   R   R¶   RJ   t   get_parent_listR|   t   label(	   t   parent_modelRJ   t   fk_namet   can_failRù   R.   R0   t   fks_to_parentR  (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   _get_foreign_keyÛ  s@    		+
'		i   c         C  sÇ   t  |  | d | ƒ} | j r' d }
 n  i | d 6| d 6| d 6| d 6|	 d 6| d 6| d	 6| d
 6| d 6|
 d 6| d 6| d 6| d 6| d 6| d 6| d 6| d 6| d 6} t | | � } | | _ | S(   u¥   
    Returns an ``InlineFormSet`` for the given kwargs.

    You must provide ``fk_name`` if ``model`` has more than one ``ForeignKey``
    to ``parent_model``.
    R'  i   u   formu   formfield_callbacku   formsetu   extrau
   can_deleteu	   can_orderu   fieldsu   excludeu   min_numu   max_numu   widgetsu   validate_minu   validate_maxu   localized_fieldsu   labelsu
   help_textsu   error_messagesu   field_classes(   R*  t   uniqueR  R  (   R&  RJ   R+   R  R'  R   R-   R  R	  Rö   R  RL   RK   R  RM   RN   RO   RP   R  R
  RQ   R  RW   R  (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   inlineformset_factory  s2    		
	R–   c           B  sB   e  Z d  Z e Z i e d ƒ d 6Z d „  Z d „  Z d „  Z	 RS(   uw   
    A basic integer field that deals with validating the given value to a
    given parent instance in an inline.
    uE   The inline foreign key did not match the parent instance primary key.u   invalid_choicec         O  s¡   | |  _  | j d t ƒ |  _ | j d d  ƒ |  _ |  j  d  k	 rz |  j rg t |  j  |  j ƒ | d <qz |  j  j | d <n  t | d <t t	 |  ƒ j
 | | Ž  d  S(   Nu   pk_fieldu   to_fieldu   initialu   required(   t   parent_instanceRa   R6   R¿   R    R"  R5   R±   Rb   R–   R]   (   R[   R-  t   argsRW   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR]   H  s    		
c         C  s‹   | |  j  k r# |  j r d  S|  j S|  j rD t |  j |  j ƒ } n |  j j } t | ƒ t | ƒ k r„ t |  j	 d d d ƒ‚ n  |  j S(   Nu   invalid_choiceR�   (
   R‰   R¿   R    R-  R"  R5   R±   R   R   RP   (   R[   Rt   t   orig(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR�   T  s    		c         C  s   t  S(   N(   R6   (   R[   R�   R%   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRñ   c  s    (
   RD   R^   R  R   R#   Rí   t   default_error_messagesR]   R�   Rñ   (    (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR–   >  s   		t   ModelChoiceIteratorc           B  s,   e  Z d  „  Z d „  Z d „  Z d „  Z RS(   c         C  s   | |  _  | j |  _ d  S(   N(   R"   R=   (   R[   R"   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR]   h  s    	c         c  sp   |  j  j d  k	 r& d |  j  j f Vn  |  j j ƒ  } | j sM | j ƒ  } n  x | D] } |  j | ƒ VqT Wd  S(   Nu    (   R"   t   empty_labelR    R=   t   allt   _prefetch_related_lookupst   iteratort   choice(   R[   R=   RÈ   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   __iter__l  s    	c         C  s)   t  |  j ƒ |  j j d  k	 r$ d n d S(   Ni   i    (   R®   R=   R"   R2  R    (   R[   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   __len__v  s    c         C  s"   |  j  j | ƒ |  j  j | ƒ f S(   N(   R"   t   prepare_valuet   label_from_instance(   R[   RÈ   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR6  y  s    (   RD   R^   R]   R7  R8  R6  (    (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR1  g  s   		
	R  c        	   B  sÃ   e  Z d  Z i e d ƒ d 6Z e Z d e d d d d d d d „ Z	 d „  Z
 d „  Z d „  Z d	 „  Z e e e ƒ Z d
 „  Z d „  Z e e e j ƒ Z d „  Z d „  Z d „  Z d „  Z RS(   u1   A ChoiceField whose choices are a model QuerySet.uG   Select a valid choice. That choice is not one of the available choices.u   invalid_choiceu	   ---------u    c
      	   O  sh   | r | d  k	 r d  |  _ n	 | |  _ t j |  | | | | | |
 | Ž | |  _ |	 |  _ | |  _ d  S(   N(   R    R2  R   R]   R=   R@   t   to_field_name(   R[   R=   R2  Rˆ   R#   R%  R�   t	   help_textR;  R@   R.  RW   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR]   ‡  s    	
		c         C  s    t  |  j ƒ r |  j ƒ  S|  j S(   u�   
        Returns ``limit_choices_to`` for this form field.

        If it is a callable, it will be invoked and the result will be
        returned.
        (   RG   R@   (   R[   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR<   ˜  s    
c         C  s@   t  t |  ƒ j | ƒ } |  j d  k	 r< |  j j ƒ  | _ n  | S(   N(   Rb   R   t   __deepcopy__R=   R    R3  (   R[   t   memot   result(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR=  £  s    c         C  s   |  j  S(   N(   RÃ   (   R[   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   _get_querysetª  s    c         C  s   | |  _  |  j |  j _ d  S(   N(   RÃ   t   choicesR#   (   R[   R=   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   _set_queryset­  s    	c         C  s
   t  | ƒ S(   uî   
        This method is used to convert objects into strings; it's used to
        generate the labels for the choices presented by this object. Subclasses
        can override this method to customize the display of the choices.
        (   R   (   R[   RÈ   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR:  µ  s    c         C  s#   t  |  d ƒ r |  j S|  j |  ƒ S(   Nu   _choices(   R;   t   _choicesR5  (   R[   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   _get_choices½  s    	c         C  sH   t  | d ƒ r2 |  j r( | j |  j ƒ S| j Sn  t t |  ƒ j | ƒ S(   Nu   _meta(   R;   R;  t   serializable_valueR±   Rb   R  R9  (   R[   Rt   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR9  Î  s
    	
c         C  s‚   | |  j  k r d  Sy, |  j p" d } |  j j i | | 6�  } Wn< t t |  j j j f k
 r} t	 |  j
 d d d ƒ‚ n X| S(   Nu   pku   invalid_choiceR�   (   R‰   R    R;  R=   RI   R|   RH   RJ   t   DoesNotExistR   RP   (   R[   Rt   t   key(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR¸   Ö  s    c         C  s   t  j |  | ƒ S(   N(   R   t   validate(   R[   Rt   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRH  à  s    c         C  s\   |  j  r t S| d  k	 r | n d } | d  k	 r7 | n d } t |  j | ƒ ƒ t | ƒ k S(   Nu    (   t   disabledR6   R    R   R9  (   R[   R�   R%   t   initial_valuet
   data_value(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRñ   ã  s
    	N(   RD   R^   R  Rí   R0  R1  R5  RF   R    R]   R<   R=  R@  RB  t   propertyR=   R:  RD  R   t   _set_choicesRA  R9  R¸   RH  Rñ   (    (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR  }  s&   								
	t   ModelMultipleChoiceFieldc           B  sŒ   e  Z d  Z e Z e Z i e d ƒ d 6e d ƒ d 6e d ƒ d 6Z e	 d d d d d „ Z d	 „  Z d
 „  Z d „  Z d „  Z d „  Z RS(   u9   A MultipleChoiceField whose choices are a model QuerySet.u   Enter a list of values.u   listuE   Select a valid choice. %(value)s is not one of the available choices.u   invalid_choiceu0   "%(pk)s" is not a valid value for a primary key.u   invalid_pk_valueu    c   	   
   O  s2   t  t |  ƒ j | d  | | | | | | | Ž d  S(   N(   Rb   RN  R]   R    (	   R[   R=   Rˆ   R#   R%  R�   R<  R.  RW   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR]   ö  s    c         C  s   | s
 g  St  |  j | ƒ ƒ S(   N(   R9   t   _check_values(   R[   Rt   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR¸   ý  s    c         C  sª   |  j  | ƒ } |  j r; | r; t |  j d d d ƒ‚ n |  j rY | rY |  j j ƒ  St | t t f ƒ sŠ t |  j d d d ƒ‚ n  |  j	 | ƒ } |  j
 | ƒ | S(   Nu   requiredR�   u   list(   R9  Rˆ   R   RP   R=   R  R   R9   RÕ   RO  t   run_validators(   R[   Rt   RÄ   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR�     s    c      	     sA  |  j  p d ‰  y t | ƒ } Wn* t k
 rK t |  j d d d ƒ‚ n Xxi | D]a } y |  j j i | ˆ  6�  WqS t t f k
 r³ t |  j d d d d i | d 6ƒ‚ qS XqS W|  j j i | d ˆ  6�  } t ‡  f d †  | Dƒ ƒ } xI | D]A } t	 | ƒ | k rø t |  j d d d d i | d	 6ƒ‚ qø qø W| S(
   u×   
        Given a list of possible PK values, returns a QuerySet of the
        corresponding objects. Raises a ValidationError if a given value is
        invalid (not a valid PK, not in the queryset, etc.)
        u   pku   listR�   u   invalid_pk_valuet   paramsu   %s__inc         3  s$   |  ] } t  t | ˆ  ƒ ƒ Vq d  S(   N(   R   R5   (   R²   R³   (   RG  (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pys	   <genexpr>+  s    u   invalid_choiceu   value(
   R;  t	   frozensetRH   R   RP   R=   R  R|   Rg   R   (   R[   Rt   R±   RÄ   t   pkst   val(    (   RG  s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRO    s0    c         C  sq   t  | d ƒ r[ t | t j ƒ r[ t  | d ƒ r[ g  | D] } t t |  ƒ j | ƒ ^ q9 St t |  ƒ j | ƒ S(   Nu   __iter__u   _meta(   R;   R   R   Rì   Rb   RN  R9  (   R[   Rt   Rw   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyR9  5  s
    )c         C  s’   |  j  r t S| d  k r" g  } n  | d  k r7 g  } n  t | ƒ t | ƒ k rS t St d „  |  j | ƒ Dƒ ƒ } t d „  | Dƒ ƒ } | | k S(   Nc         s  s   |  ] } t  | ƒ Vq d  S(   N(   R   (   R²   Rt   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pys	   <genexpr>E  s    c         s  s   |  ] } t  | ƒ Vq d  S(   N(   R   (   R²   Rt   (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pys	   <genexpr>F  s    (   RI  R6   R    R®   RF   Rg   R9  (   R[   R�   R%   t   initial_sett   data_set(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRñ   <  s    			N(   RD   R^   R  R   R#   R   t   hidden_widgetRí   R0  RF   R    R]   R¸   R�   RO  R9  Rñ   (    (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyRN  ë  s   				%	c         C  s=   |  d  k	 o< t |  d ƒ o< |  j j d  k	 p< |  j j d  k	 S(   Nu   _meta(   R    R;   R   R   R-   (   t
   form_class(    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   modelform_defines_fieldsJ  s    N(@   R  t
   __future__R    t   collectionsR   t	   itertoolsR   t   django.core.exceptionsR   R   R   R   t   django.forms.fieldsR   R   t   django.forms.formsR	   R
   t   django.forms.formsetsR   R   t   django.forms.utilsR   t   django.forms.widgetsR   R   R   t   django.utilsR   t   django.utils.encodingR   t   django.utils.textR   R   t   django.utils.translationR   R   Rí   t   __all__RE   R    R1   R:   RA   RF   RY   R£   RZ   R_   Rd   t   with_metaclassR¢   Rª   R«   R6   R  R  R*  R,  R–   R1  R  RN  RY  (    (    (    s5   /tmp/pip-unpacked-wheel-4tV8Ix/django/forms/models.pyt   <module>   sn   "		'			WI¾"			Rÿ 			k7			&)n_