agateblue / agateblue/django-dynamic-preferences

'NoneType' object has no attribute '__name__'

Đang mở
#173 12 bình luận 0 reaction 0 người được giao Xem trên GitHub
Ngôn ngữ chính
Python
Star
359
Fork
86
Chỉ số merge pull request
Không có pull request nào được merge trong 30 ngày

Mô tả

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

Hướng dẫn đóng góp

Mở hướng dẫn đóng góp

Đánh giá

Issue này chưa được đánh giá.

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.