AppConfig Application Configuration - Configurable Attributes

 AppConfig:

  • Application Configuration objects store metadata for an application. Some attributes can be configured in AppConfig subclasses. 
  • Others are set by Django and read-only.

AppConfig.name: 

  • Full Python path to the application, ex. 'django.contrib.admin'.
  • AppConfig.name attribute defines which application the configuration applies to. 
  • It must be set in all AppConfig subclasses.
  • It must be unique across a Django project.

AppConfig.label: 
  • Short name for the application, ex. 'admin'
  • This attribute allows relabeling an application when two applications have conflicting labels. 
  • It defaults to the last component of name. 
  • It should be a valid Python identifier.
  • It must be unique across a Django project.

AppConfig.verbose_name:
  • Human Readable name for the Application, ex. “Administration”.
  • This attribute defaults to label.title().
AppConfig.path:
  • File System Path to the application directory, ex. '/usr/lib/pythonX.Y/dist-packages/django/contrib/admin'.
  • Django can automatically detect and set this, but we can also provide an explicit override as a class attribute on your AppConfig subclass. 
  • In a few situations this is required; for example if the app package is a namespace package with multiple paths.
AppConfig.default:
  • Set this attribute to False to prevent Django from selecting a configuration class automatically. 
  • This is useful when apps.py defines only one AppConfig subclass but you do not want Django to use it by default.
  • Set this attribute to True to tell Django to select a configuration class automatically. This is useful when apps.py defines more than one AppConfig subclass and you want Django to use one of them by default.
  • By default, this attribute isn’t set.
AppConfig.default_auto_field:
  • The implicit primary key type to add to models within this app. 
  • You can use this to keep AutoField as the primary key type for third party applications.
  • By default, this is the value of DEFAULT_AUTO_FIELD.

Comments

Popular posts from this blog

Internationalization (Language Setting) in Django

reverse_lazy() Method in Django

CharFilter in Django