Browse Source

Django autofields (#429)

Added settings for Default Auto Fields for Django 3.2

Co-authored-by: Vince Salvino <salvino@coderedcorp.com>
Roxanna Coldiron 3 years ago
parent
commit
01f605f37f

+ 9 - 0
coderedcms/apps.py

@@ -0,0 +1,9 @@
+from django.apps import AppConfig
+
+
+class CoderedcmsConfig(AppConfig):
+    name = 'coderedcms'
+    verbose_name = 'CodeRed CMS'
+    # TODO: At some point in the future, change this to BigAutoField and create
+    # the corresponding migration for concrete models in coderedcms.
+    default_auto_field = 'django.db.models.AutoField'

+ 5 - 0
coderedcms/project_template/basic/project_name/settings/base.py

@@ -203,3 +203,8 @@ BOOTSTRAP4 = {
 # Tags
 
 TAGGIT_CASE_INSENSITIVE = True
+
+
+# Sets default for primary key IDs
+# See https://docs.djangoproject.com/en/{{ docs_version }}/ref/models/fields/#bigautofield
+DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

+ 5 - 0
coderedcms/project_template/sass/project_name/settings/base.py

@@ -198,3 +198,8 @@ BOOTSTRAP4 = {
 # Tags
 
 TAGGIT_CASE_INSENSITIVE = True
+
+
+# Sets default for primary key IDs
+# See https://docs.djangoproject.com/en/{{ docs_version }}/ref/models/fields/#bigautofield
+DEFAULT_AUTO_FIELD = 'django.db.models.BigAutoField'

+ 2 - 0
coderedcms/tests/settings.py

@@ -208,5 +208,7 @@ WAGTAIL_CACHE = False
 
 SECRET_KEY = 'not needed'
 
+DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'
+
 NOSE_ARGS = ['--nocapture',
              '--nologcapture', ]

+ 4 - 0
docs/releases/v0.21.0.rst

@@ -25,6 +25,10 @@ Upgrade considerations
 * ``coderedcms.blocks.MultiSelectBlock`` has been removed and is now replaced
   with ``wagtail.core.blocks.MultipleChoiceBlock``.
 
+* CodeRed CMS now sets ``default_auto_field = 'django.db.models.AutoField'`` for
+  its own concrete models. If you had previously manually specified a different
+  ``DEFAULT_AUTO_FIELD`` Django setting, you may need to create a migration.
+
 * You may need to find/replace
   ``coderedcms.blocks.base_blocks.MultiSelectBlock`` with
   ``wagtail.core.blocks.MultipleChoiceBlock`` in any old migrations so that they

+ 3 - 0
tutorial/mysite/mysite/settings/base.py

@@ -203,3 +203,6 @@ BOOTSTRAP4 = {
 # Tags
 
 TAGGIT_CASE_INSENSITIVE = True
+
+
+DEFAULT_AUTO_FIELD = 'django.db.models.AutoField'

+ 1 - 1
tutorial/mysite/requirements.txt

@@ -1,4 +1,4 @@
-coderedcms==0.20.*
+coderedcms==0.21.*
 
 # django_sendmail_backend enables sending email from your web host server.
 # Remove this if using a different email backend.

+ 1 - 0
tutorial/mysite/website/apps.py

@@ -2,4 +2,5 @@ from django.apps import AppConfig
 
 
 class WebsiteConfig(AppConfig):
+    default_auto_field = 'django.db.models.AutoField'
     name = 'website'