You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
If this is new to you, you ought to read the `official Django tutorial
75
67
<https://docs.djangoproject.com/en/3.2/intro/tutorial01/>`_, which covers starting a new project.
76
68
69
+
It installs additional optional packages which are used in the template project. Those are
70
+
71
+
* `djangocms-text-ckeditor <https://github.com/django-cms/djangocms-text-ckeditor>`_ for rich text input.
72
+
* `djangocms-frontend <https://github.com/django-cms/djangocms-frontend>`_ for `Bootstrap5 <https://getbootstrap.com>`_ support.
73
+
* `django-filer <https://github.com/django-cms/django-filer>`_ for managing media files like images.
74
+
* `djangocms_admin_style <https://github.com/django-cms/djangocms-admin-style>`_ for a consistent user experience with django CMS and Django admin.
75
+
77
76
Your new project will look like this::
78
77
79
-
myproject
80
-
myproject
78
+
myproject/
79
+
LICENSE
80
+
README.md
81
+
db.sqlite3
82
+
myproject/
83
+
static/
84
+
templates/
85
+
base.html
81
86
__init__.py
82
87
asgi.py
83
88
settings.py
84
89
urls.py
85
90
wsgi.py
86
91
manage.py
92
+
requirements.in
93
+
94
+
The ``LICENSE`` and ``README.md`` files are not needed and can be deleted or replaced by appropriate files for your project.
95
+
96
+
``requirements.in`` contains dependencies for the project. Add your dependencies here. We suggest to use `pip-compile <https://github.com/jazzband/pip-tools>`_ to freeze your requirements as, for example, discussed in `this blog post <https://blog.typodrive.com/2020/02/04/always-freeze-requirements-with-pip-compile-to-avoid-unpleasant-surprises/>`_.
97
+
98
+
Now, enter the project directory and create the database::
99
+
100
+
cd myproject
101
+
python -m manage migrate
102
+
103
+
To run the project, you at least need a superuser to log in::
104
+
105
+
python -m manage createsuperuser
106
+
107
+
Finally, run the ``cms check`` command to see if everything worked fine::
108
+
109
+
python -m manage cms check
110
+
111
+
Fix any errors that are displayed. Once done, you are ready to spin up Django's development server by running::
112
+
113
+
python -m manage runserver
114
+
115
+
You can visit your project's web site by pointing your browser to ``localhost:8000``.
116
+
117
+
Use the newly created superuser's credentials to authenticate and create your first page!
Open the new project's ``settings.py`` file in your text editor.
128
+
django CMS is nothing more than a powerful set of Django apps. Hence you can add django CMS to any Django project. It might require some settings and URLs to be modified, however. The template project comes with suitable settings. When adding django CMS to your existing project, you need to adjust the settings yourself.
129
+
130
+
Open the your project's ``settings.py`` file in your text editor.
94
131
95
132
96
133
INSTALLED_APPS
@@ -103,11 +140,9 @@ You will need to add the following to its list of ``INSTALLED_APPS``::
103
140
'menus',
104
141
'treebeard',
105
142
106
-
* django CMS needs to use Django's :mod:`django:django.contrib.sites` framework. You'll need to set a ``SITE_ID``
107
-
in the settings - ``SITE_ID = 1`` will suffice.
143
+
* django CMS needs to use Django's :mod:`django:django.contrib.sites` framework. You'll need to set a ``SITE_ID`` in the settings - ``SITE_ID = 1`` will suffice.
108
144
* ``cms`` and ``menus`` are the core django CMS modules.
109
-
* `django-treebeard <http://django-treebeard.readthedocs.io>`_ is used to manage django CMS's page and plugin tree
110
-
structures.
145
+
* `django-treebeard <http://django-treebeard.readthedocs.io>`_ is used to manage django CMS's page and plugin tree structures.
This provides some styling that helps make django CMS administration components easier to work with.
@@ -136,13 +171,12 @@ For example::
136
171
``LANGUAGE_CODE`` setting to ``en``.)
137
172
138
173
139
-
********
140
-
Database
141
-
********
174
+
Database settings
175
+
=================
142
176
143
-
django CMS requires a relational database backend. Each django CMS installation should have its own database.
177
+
django CMS requires a relational database backend. Each django CMS installation should have its own database. If you're adding django CMS to an existing project, you will most likely already have your database configured.
144
178
145
-
You can use SQLite, which is included in Python and doesn't need to be installed separately or configured further. You
179
+
If not, you can use SQLite, which is included in Python and doesn't need to be installed separately or configured further. You
146
180
are unlikely to be using that for a project in production, but it's ideal for development and exploration, especially
147
181
as it is configured by default in a new Django project's :setting:`django:DATABASES`::
148
182
@@ -173,39 +207,12 @@ as it is configured by default in a new Django project's :setting:`django:DATABA
173
207
for your chosen database backend.
174
208
175
209
176
-
Database tables
177
-
===============
210
+
Migrating database tables
211
+
=========================
178
212
179
213
Now run migrations to create database tables for the new applications::
180
214
181
-
python manage.py migrate
182
-
183
-
184
-
Admin user
185
-
==========
186
-
187
-
Create an admin superuser::
188
-
189
-
python manage.py createsuperuser
190
-
191
-
192
-
*************************************
193
-
Using ``cms check`` for configuration
194
-
*************************************
195
-
196
-
Once you have completed the minimum required set-up described above, you can use django CMS's built-in ``cms check``
197
-
command to help you identify and install other components. Run::
198
-
199
-
python manage.py cms check
200
-
201
-
This will check your configuration, your applications and your database, and report on any problems.
202
-
203
-
.. note::
204
-
205
-
If key components are be missing, django CMS will be unable to run the ``cms check command`` and will simply raise
206
-
an error instead.
207
-
208
-
After each of the steps below run ``cms check`` to verify that you have resolved that item in its checklist.
215
+
python -m manage migrate
209
216
210
217
211
218
Sekizai
@@ -279,12 +286,8 @@ Also add ``'django.template.context_processors.i18n'`` if it's not already prese
279
286
required however.
280
287
281
288
282
-
******************************
283
-
Further required configuration
284
-
******************************
285
-
286
-
URLs
287
-
====
289
+
Adding django CMS' URLs
290
+
=======================
288
291
289
292
In the project's ``urls.py``, add ``re_path(r'^', include('cms.urls'))`` to the ``urlpatterns`` list. It should come after
290
293
other patterns, so that specific URLs for other applications can be detected first.
@@ -304,7 +307,7 @@ The django CMS project will now run, as you'll see if you launch it with
304
307
305
308
.. code-block:: bash
306
309
307
-
python manage.py runserver
310
+
python -m manage runserver
308
311
309
312
310
313
You'll be able to reach it at http://localhost:8000/, and the admin at http://localhost:8000/admin/. You won't yet actually be able to
@@ -414,6 +417,23 @@ work in your ``urls.py``:
414
417
(See the Django documentation for guidance on :doc:`serving media files in production
415
418
<django:howto/static-files/index>`.)
416
419
420
+
Using ``cms check`` for configuration
421
+
=====================================
422
+
423
+
Once you have completed the minimum required set-up described above, you can use django CMS's built-in ``cms check``
424
+
command to help you identify and install other components. Run::
425
+
426
+
python -m manage cms check
427
+
428
+
This will check your configuration, your applications and your database, and report on any problems.
429
+
430
+
.. note::
431
+
432
+
If key components are be missing, django CMS will be unable to run the ``cms check command`` and will simply raise
433
+
an error instead.
434
+
435
+
After each of the steps below run ``cms check`` to verify that you have resolved that item in its checklist.
436
+
417
437
418
438
*************************************
419
439
Adding content-handling functionality
@@ -442,8 +462,8 @@ To install::
442
462
pip install django-filer
443
463
444
464
A number of applications will be installed as dependencies. `Easy Thumbnails
445
-
<https://github.com/SmileyChris/easy-thumbnails>`_ is required to create new versions of images in different sizes;
446
-
`Django MPTT <https://github.com/django-mptt/django-mptt/>`_ manages the tree structure of the folders in Django Filer.
465
+
<https://github.com/SmileyChris/easy-thumbnails>`_ is required to create new versions of images in different sizes; in older versions of Django Filer
466
+
`Django MPTT <https://github.com/django-mptt/django-mptt/>`_ manages the tree structure of the folders in Django Filer - you will not need it if you use Django Filer version 3 and above.
447
467
448
468
Pillow, the Python imaging library, will be installed. `Pillow <https://github.com/python-pillow/Pillow>`_ needs some
449
469
system-level libraries - the `Pillow documentation <https://pillow.readthedocs.io>`_ describes in detail what is
@@ -453,7 +473,6 @@ Add::
453
473
454
474
'filer',
455
475
'easy_thumbnails',
456
-
'mptt',
457
476
458
477
to ``INSTALLED_APPS``.
459
478
@@ -470,10 +489,10 @@ You also need to add::
470
489
471
490
New database tables will need to be created for Django Filer and Easy Thumbnails, so run migrations::
472
491
473
-
python manage.py migrate filer
474
-
python manage.py migrate easy_thumbnails
492
+
python -m manage migrate filer
493
+
python -m manage migrate easy_thumbnails
475
494
476
-
(or simply, ``python manage.py migrate``).
495
+
(or simply, ``python -m manage migrate``).
477
496
478
497
479
498
Django CMS CKEditor
@@ -489,7 +508,7 @@ Add ``djangocms_text_ckeditor`` to your ``INSTALLED_APPS``.
489
508
490
509
Run migrations::
491
510
492
-
python manage.py migrate djangocms_text_ckeditor
511
+
python -m manage migrate djangocms_text_ckeditor
493
512
494
513
495
514
Miscellaneous plugins
@@ -524,27 +543,12 @@ to ``INSTALLED_APPS``.
524
543
525
544
Then run migrations::
526
545
527
-
python manage.py migrate
546
+
python -m manage migrate
528
547
529
548
These and other plugins are described in more detail in :ref:`commonly-used-plugins`. More are listed
530
549
plugins available on the `django CMS Marketplace <https://marketplace.django-cms.org/en/addons/>`_.
531
550
532
551
533
-
******************
534
-
Launch the project
535
-
******************
536
-
537
-
Start up the runserver::
538
-
539
-
python manage.py runserver
540
-
541
-
and access the new site, which you should now be able to reach at ``http://localhost:8000``. Login if you haven't
0 commit comments