Kaydet (Commit) 13be4530 authored tarafından Simon Charette's avatar Simon Charette Kaydeden (comit) Tim Graham

Refs #28492 -- Stopped accessing settings at Field.db_tablespace initialization.

Deferring accesses to settings allows database fields to be initialized before
settings are loaded.
üst c466ef3b
......@@ -158,7 +158,7 @@ class Field(RegisterLookupMixin):
self.help_text = help_text
self.db_index = db_index
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
# Adjust the appropriate creation counter, and save our local copy.
......@@ -423,7 +423,7 @@ class Field(RegisterLookupMixin):
"choices": [],
"help_text": '',
"db_column": None,
"db_tablespace": settings.DEFAULT_INDEX_TABLESPACE,
"db_tablespace": None,
"auto_created": False,
"validators": [],
"error_messages": None,
......@@ -433,8 +433,9 @@ class Field(RegisterLookupMixin):
"error_messages": "_error_messages",
"validators": "_validators",
"verbose_name": "_verbose_name",
"db_tablespace": "_db_tablespace",
}
equals_comparison = {"choices", "validators", "db_tablespace"}
equals_comparison = {"choices", "validators"}
for name, default in possibles.items():
value = getattr(self, attr_overrides.get(name, name))
# Unroll anything iterable for choices into a concrete list
......@@ -688,6 +689,10 @@ class Field(RegisterLookupMixin):
def unique(self):
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):
if not self.name:
self.name = name
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment