예제 #1
0
 def __init__(self, *args, **kwargs):
     ModelForm.__init__(self, *args, **kwargs)
     if self.instance:
         try:
             self.fields["custom_operation"].initial = self.instance.operation.operation_id
         except:
             pass
예제 #2
0
 def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, 
     initial=None, error_class=ErrorList, label_suffix=':', 
     empty_permitted=False, instance=None, usuario=None):
     ModelForm.__init__(self, data=data, files=files, auto_id=auto_id, prefix=prefix, initial=initial, error_class=error_class, label_suffix=label_suffix, empty_permitted=empty_permitted, instance=instance)
     unidades = [(0, "------------")]
     for unidad in usuario.unidades_responsable.all():
         unidades.append( (unidad.id,unidad.nombre) )
     self.fields['unidad'].choices = unidades
예제 #3
0
    def __init__(self, *args, **kwargs):
        """

        Arguments:
        - `self`:
        - `*args`:
        - `**kwargs`:

        Return:
        Exceptions:
        """
        ModelForm.__init__(self, *args, **kwargs)
예제 #4
0
    def __init__(self, *args, **kwargs):
        """

        Arguments:
        - `self`:
        - `*args`:
        - `**kwargs`:

        Return:
        Exceptions:
        """
        ModelForm.__init__(self, *args, **kwargs)
예제 #5
0
def form_init(self, *args, **kwargs):

    # call class super initialisation
    ModelForm.__init__(self, *args, **kwargs)

    # check model is in dictionary
    if self.Meta.model in absFields:

        # get fields specific to this model
        fieldsDict = absFields[self.Meta.model]

        # if field is in required list of absolutes set absolute value in dict
        newValues = {
            f: abs(getattr(self.instance, f))
            for f in self.Meta.fields if f in fieldsDict
        }

        # update initial dict
        self.initial.update(newValues)
예제 #6
0
 def __init__(self, data=None, files=None, initial=None):
     data = self.remove_initial_values(data)
     ModelForm.__init__(self, data=data, files=files, initial=initial)
     self.set_initial_values()
예제 #7
0
 def __init__(self, data=None, files=None, auto_id='id_%s', prefix=None, 
     initial=None, error_class=ErrorList, label_suffix=':', 
     empty_permitted=False, instance=None, paso = None):
     ModelForm.__init__(self, data=data, files=files, auto_id=auto_id, prefix=prefix, initial=initial, error_class=error_class, label_suffix=label_suffix, empty_permitted=empty_permitted, instance=instance)
     self.fields['paso'].choices = (paso.id, paso.nombre)
     self.fields['paso'].initial = paso.id