Django custom configuration error: AttributeError:'Settings' object has no attribute'HBase'
If we need to use Hbase
, we can imitate the Mysql
and write the relevant information configuration into the settings
file, but I encountered a problem, that is, it cannot be imported.
In [12]: settings.HBASE
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-12-22bd47148938> in <module>
----> 1 settings.HBASE
~\.virtualenvs\twitter-5Z0qCgub\lib\site-packages\django\conf\__init__.py in __getattr__(self, name)
81 if self._wrapped is empty:
82 self._setup(name)
---> 83 val = getattr(self._wrapped, name)
84
85 # Special case some settings which require further modification.
AttributeError: 'Settings' object has no attribute 'HBASE'
In [13]: settings.HBase
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-13-1ee0306304e8> in <module>
----> 1 settings.HBase
~\.virtualenvs\twitter-5Z0qCgub\lib\site-packages\django\conf\__init__.py in __getattr__(self, name)
81 if self._wrapped is empty:
82 self._setup(name)
---> 83 val = getattr(self._wrapped, name)
84
85 # Special case some settings which require further modification.
AttributeError: 'Settings' object has no attribute 'HBase'
The results of the investigation to find the problem, in Django
profile settings
, you must use the full size in order to be imported.
HBase
--> HBASE
HBase = {
'default': {
'HOST': '192.168.31.245',
'PORT': 9090
}
}
Needs to be changed to
HBASE = {
'default': {
'HOST': '192.168.31.245',
'PORT': 9090
}
}
Django
error! Do not mix capitalization in the configuration filesettings
, it must be all uppercase!
You can see the key code if setting.isupper():
django/conf/__init__.py
class Settings:
def __init__(self, settings_module):
# update this dict from global settings (but only for ALL_CAPS settings)
for setting in dir(global_settings):
if setting.isupper():
setattr(self, setting, getattr(global_settings, setting))
# store the settings module in case someone later cares
self.SETTINGS_MODULE = settings_module
mod = importlib.import_module(self.SETTINGS_MODULE)
tuple_settings = (
"INSTALLED_APPS",
"TEMPLATE_DIRS",
"LOCALE_PATHS",
)
self._explicit_settings = set()
for setting in dir(mod):
if setting.isupper():
setting_value = getattr(mod, setting)
if (setting in tuple_settings and
not isinstance(setting_value, (list, tuple))):
raise ImproperlyConfigured("The %s setting must be a list or a tuple. " % setting)
setattr(self, setting, setting_value)
self._explicit_settings.add(setting)
**粗体** _斜体_ [链接](http://example.com) `代码` - 列表 > 引用
。你还可以使用@
来通知其他用户。