django-cms中settings.py文件位置及数据库连接方式咨询
Hey there! Let's start by clearing up a key confusion: django-cms isn't a standalone Django project—it's a reusable Django application that integrates into your existing Django project. That’s why you won’t find a settings.py file inside the django-cms package itself.
Where to Find settings.py
The settings.py file belongs to your own Django project, not the django-cms library. Here’s how it works depending on your setup:
- If you used the official
djangocms-installertool to create a project with django-cms pre-configured, yoursettings.pylives in the root directory of the generated project (just like a standard Django project). - If you added django-cms to an existing Django project manually, you’ll use the
settings.pythat’s already part of your project. You’ll just need to add django-cms and its dependencies to theINSTALLED_APPSlist in this file.
How Database Connection Works
Django-CMS doesn’t have its own separate database configuration—it fully reuses the database settings from your project’s settings.py. Here’s the breakdown:
- Your project’s
settings.pydefines the database connection via theDATABASESdictionary (e.g., for PostgreSQL, MySQL, SQLite, etc.). - When you install django-cms and run
python manage.py migrate, django-cms applies its own database migrations to your project’s database. This creates all necessary tables (likecms_page,cms_title,cms_plugin) that django-cms needs to store its content. - All django-cms data (pages, plugins, configurations) lives right alongside your project’s other data in the same database.
Quick Tip
If you used djangocms-installer, it automatically populates your settings.py with all required django-cms configurations:
- Adds django-cms core apps (
cms,treebeard,menus, etc.) toINSTALLED_APPS - Updates
MIDDLEWAREandTEMPLATESto include django-cms components - Sets up required context processors and other CMS-specific settings
内容的提问来源于stack exchange,提问作者Siraj Alam

