2

In django/django/db/models/fields/__init__.py there's variable:

__all__ = [
    'AutoField', 'BLANK_CHOICE_DASH', 'BigAutoField', 'BigIntegerField',
    'BinaryField', 'BooleanField', 'CharField', 'CommaSeparatedIntegerField',
    'DateField', 'DateTimeField', 'DecimalField', 'DurationField',
    'EmailField', 'Empty', 'Field', 'FieldDoesNotExist', 'FilePathField',
    'FloatField', 'GenericIPAddressField', 'IPAddressField', 'IntegerField',
    'NOT_PROVIDED', 'NullBooleanField', 'PositiveIntegerField',
    'PositiveSmallIntegerField', 'SlugField', 'SmallIntegerField', 'TextField',
    'TimeField', 'URLField', 'UUIDField',
]

How Django retrieves the variable __all__? Is it fields.__init__.__all__ or fields.__all__?

Selcuk
  • 57,004
  • 12
  • 102
  • 110
AbstProcDo
  • 19,953
  • 19
  • 81
  • 138

1 Answers1

2

Django does not directly use that variable but it is used by Python import statement. You can do the following if you want to access the value:

from django.db.models import fields
print(fields.__all__)

See this question for an explanation.

Selcuk
  • 57,004
  • 12
  • 102
  • 110