MCPcopy
hub / github.com/django/django / __init__

Method __init__

django/forms/models.py:348–394  ·  view source on GitHub ↗
(
        self,
        data=None,
        files=None,
        auto_id="id_%s",
        prefix=None,
        initial=None,
        error_class=ErrorList,
        label_suffix=None,
        empty_permitted=False,
        instance=None,
        use_required_attribute=None,
        renderer=None,
    )

Source from the content-addressed store, hash-verified

346
347class BaseModelForm(BaseForm, AltersData):
348 def __init__(
349 self,
350 data=None,
351 files=None,
352 auto_id="id_%s",
353 prefix=None,
354 initial=None,
355 error_class=ErrorList,
356 label_suffix=None,
357 empty_permitted=False,
358 instance=None,
359 use_required_attribute=None,
360 renderer=None,
361 ):
362 opts = self._meta
363 if opts.model is None:
364 raise ValueError("ModelForm has no model class specified.")
365 if instance is None:
366 # if we didn't get an instance, instantiate a new one
367 self.instance = opts.model()
368 object_data = {}
369 else:
370 self.instance = instance
371 object_data = model_to_dict(instance, opts.fields, opts.exclude)
372 # if initial was provided, it should override the values from instance
373 if initial is not None:
374 object_data.update(initial)
375 # self._validate_(unique|constraints) will be set to True by
376 # BaseModelForm.clean(). It is False by default so overriding
377 # self.clean() and failing to call super will stop
378 # validate_(unique|constraints) from being called.
379 self._validate_unique = False
380 self._validate_constraints = False
381 super().__init__(
382 data,
383 files,
384 auto_id,
385 prefix,
386 object_data,
387 error_class,
388 label_suffix,
389 empty_permitted,
390 use_required_attribute=use_required_attribute,
391 renderer=renderer,
392 )
393 for formfield in self.fields.values():
394 apply_limit_choices_to_to_formfield(formfield)
395
396 def _get_validation_exclusions(self):
397 """

Callers 5

__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45
__init__Method · 0.45

Calls 5

model_to_dictFunction · 0.85
modelMethod · 0.45
updateMethod · 0.45
valuesMethod · 0.45

Tested by

no test coverage detected