Refs #28492 -- Stopped accessing settings at Field.db_tablespace initialization.
Deferring accesses to settings allows database fields to be initialized before settings are loaded.
This commit is contained in:
parent
c466ef3b34
commit
13be453080
|
@ -158,7 +158,7 @@ class Field(RegisterLookupMixin):
|
||||||
self.help_text = help_text
|
self.help_text = help_text
|
||||||
self.db_index = db_index
|
self.db_index = db_index
|
||||||
self.db_column = db_column
|
self.db_column = db_column
|
||||||
self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
|
self._db_tablespace = db_tablespace
|
||||||
self.auto_created = auto_created
|
self.auto_created = auto_created
|
||||||
|
|
||||||
# Adjust the appropriate creation counter, and save our local copy.
|
# Adjust the appropriate creation counter, and save our local copy.
|
||||||
|
@ -423,7 +423,7 @@ class Field(RegisterLookupMixin):
|
||||||
"choices": [],
|
"choices": [],
|
||||||
"help_text": '',
|
"help_text": '',
|
||||||
"db_column": None,
|
"db_column": None,
|
||||||
"db_tablespace": settings.DEFAULT_INDEX_TABLESPACE,
|
"db_tablespace": None,
|
||||||
"auto_created": False,
|
"auto_created": False,
|
||||||
"validators": [],
|
"validators": [],
|
||||||
"error_messages": None,
|
"error_messages": None,
|
||||||
|
@ -433,8 +433,9 @@ class Field(RegisterLookupMixin):
|
||||||
"error_messages": "_error_messages",
|
"error_messages": "_error_messages",
|
||||||
"validators": "_validators",
|
"validators": "_validators",
|
||||||
"verbose_name": "_verbose_name",
|
"verbose_name": "_verbose_name",
|
||||||
|
"db_tablespace": "_db_tablespace",
|
||||||
}
|
}
|
||||||
equals_comparison = {"choices", "validators", "db_tablespace"}
|
equals_comparison = {"choices", "validators"}
|
||||||
for name, default in possibles.items():
|
for name, default in possibles.items():
|
||||||
value = getattr(self, attr_overrides.get(name, name))
|
value = getattr(self, attr_overrides.get(name, name))
|
||||||
# Unroll anything iterable for choices into a concrete list
|
# Unroll anything iterable for choices into a concrete list
|
||||||
|
@ -688,6 +689,10 @@ class Field(RegisterLookupMixin):
|
||||||
def unique(self):
|
def unique(self):
|
||||||
return self._unique or self.primary_key
|
return self._unique or self.primary_key
|
||||||
|
|
||||||
|
@property
|
||||||
|
def db_tablespace(self):
|
||||||
|
return self._db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
|
||||||
|
|
||||||
def set_attributes_from_name(self, name):
|
def set_attributes_from_name(self, name):
|
||||||
if not self.name:
|
if not self.name:
|
||||||
self.name = name
|
self.name = name
|
||||||
|
|
Loading…
Reference in New Issue