Home > Back-end >  How does the Django setting of letting it know about your app really work?
How does the Django setting of letting it know about your app really work?

Time:10-12

I've been learning django for a few weeks , but i still cant fully understand how some of the settings really work,like the most basic one that when i create a new app called 'base' inside my django project then i should let django know about my app so i write like as most of the people do

'INSTALLED_APPS = [
  'django.contrib.admin',
  'django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions',
  'django.contrib.messages',
  'django.contrib.staticfiles',

  'base.apps.BaseConfig',

]'

but if i write just only my app name 'base' , it still works , so can someone tell me what is the difference between this two?

'INSTALLED_APPS = [
  'django.contrib.admin',
  'django.contrib.auth',
  'django.contrib.contenttypes',
  'django.contrib.sessions',
  'django.contrib.messages',
  'django.contrib.staticfiles',

  'base',

]'

CodePudding user response:

There is no that much difference.

It's better to create CustomAppConfig, Because you can tune different parameters like name, label, a verbose_name for admin panel.

CodePudding user response:

Generally you can consider base as shortname of your application and base.apps.BaseConfig as its longname. If you are working on a simple project you can go on with base, but if you want to have specific configurations for an application you should use base.apps.BaseConfig.

According to django documentation you'd better to define a subclass of AppConfig in your app's apps.py and use the dotted path (longname) base.apps.BaseConfig in INSTALLED_APPS.

See the Configurable Attributes of AppConfig class for details.

  • Related