agateblue / agateblue/django-dynamic-preferences

'NoneType' object has no attribute '__name__'

オープン
#173 コメント 12 件 リアクション 0 件 担当者 0 名 GitHub で見る
主要言語
Python
スター
359
フォーク
86
PR マージ指標
30日以内にマージされた PR はありません

説明

I have installed the library, define a preference , but when try to use it in my code, I got this.

```
File "/home/gonzalo/Playground/tektank-ws/tektank/tektank/apps/entities/models.py", line 27, in _validate_dob
oag = global_preferences['general__oldest_allowed_age']
File "/home/gonzalo/.virtualenvs/tektank-ws/lib/python3.6/site-packages/dynamic_preferences/managers.py", line 29, in __getitem__
return self.get(key)
File "/home/gonzalo/.virtualenvs/tektank-ws/lib/python3.6/site-packages/dynamic_preferences/managers.py", line 133, in get
return self.from_cache(section, name)
File "/home/gonzalo/.virtualenvs/tektank-ws/lib/python3.6/site-packages/dynamic_preferences/managers.py", line 63, in from_cache
self.get_cache_key(section, name), CachedValueNotFound)
File "/home/gonzalo/.virtualenvs/tektank-ws/lib/python3.6/site-packages/dynamic_preferences/managers.py", line 57, in get_cache_key
return 'dynamic_preferences_{0}_{1}_{2}'.format(self.model.__name__, section, name)
AttributeError: 'NoneType' object has no attribute '__name__'

```

This is my code:

```
from dynamic_preferences.registries import global_preferences_registry
global_preferences = global_preferences_registry.manager()

def _validate_dob(value):
oag = global_preferences['general__oldest_allowed_age']
yag = global_preferences['general__youngest_allowed_age']
if not oag <= value <= yag:
raise ValidationError(
_("Date must be between %(oag)s and %(yag)s"),
code='invalid_model_data',
params={'oag':oag.strftime("%x"), 'yag':yag.strftime("%x")},
)

```
I found this issue, but it does not give the solution with code.
https://github.com/EliotBerriot/django-dynamic-preferences/issues/163

コントリビューションガイド

コントリビューションガイドを開く

評価

この issue はまだ評価されていません。

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。