Search code examples
djangodjango-templatesblogsweb-development-serverdjango-settings

Adding apps sequence in Installed apps section in setting.py in django


i wanted to add my blog app templates so i just addes blog.apps.BlogConfig in my installed apps section but here's what i found

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

] adding blog.app at the top section gave an error of "no module name .." but

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

]

adding in the end worked fine ...i wanted to know why did it work and how does this sequence effects and in the tutorial the person added blog.apps.blogConfig at the starting but worked for him(version 2.0) and my version is also the same .


Solution

  • Please refer to this documentation page, which is about the contenttypes module.

    Django includes a contenttypes application that can track all of the models installed in your Django-powered project

    For a blog application, you most likely had models in there. Besides, as blogs should belong to a user, you need the authentication and sessions module; if you used the {% load static %} tag in your HTML files, you need the staticfiles module.

    If you load your application before Django loads its modules, things will not work correctly, and that's why you only load your own things after Django completed loading its own.