summaryrefslogtreecommitdiff
path: root/django/apps
diff options
context:
space:
mode:
authorTom Forbes <tom@tomforb.es>2020-07-12 13:59:57 +0100
committerMariusz Felisiak <felisiak.mariusz@gmail.com>2020-12-15 11:25:46 +0100
commitb5e12d490af3debca8c55ab3c1698189fdedbbdb (patch)
tree5fe3005ac567f3addf78b81ae033191e2fa642f4 /django/apps
parentb960e4ed722a04a9db0d35293f76e253eedf9126 (diff)
Fixed #31007 -- Allowed specifying type of auto-created primary keys.
This also changes the default type of auto-created primary keys for new apps and projects to BigAutoField.
Diffstat (limited to 'django/apps')
-rw-r--r--django/apps/config.py10
1 files changed, 10 insertions, 0 deletions
diff --git a/django/apps/config.py b/django/apps/config.py
index 928e19ac44..6d794eee3a 100644
--- a/django/apps/config.py
+++ b/django/apps/config.py
@@ -5,6 +5,7 @@ from importlib import import_module
from django.core.exceptions import ImproperlyConfigured
from django.utils.deprecation import RemovedInDjango41Warning
+from django.utils.functional import cached_property
from django.utils.module_loading import import_string, module_has_submodule
APPS_MODULE_NAME = 'apps'
@@ -55,6 +56,15 @@ class AppConfig:
def __repr__(self):
return '<%s: %s>' % (self.__class__.__name__, self.label)
+ @cached_property
+ def default_auto_field(self):
+ from django.conf import settings
+ return settings.DEFAULT_AUTO_FIELD
+
+ @property
+ def _is_default_auto_field_overridden(self):
+ return self.__class__.default_auto_field is not AppConfig.default_auto_field
+
def _path_from_module(self, module):
"""Attempt to determine app's filesystem path from its module."""
# See #21874 for extended discussion of the behavior of this method in