我想使用這個庫的Django:Django的Pgencrypt - AttributeError的:「上校」對象有沒有屬性「源」
https://github.com/dcwatson/django-pgcrypto/
我試圖建立我的領域是這樣的:
username = pgcrypto.EncryptedTextField(cipher='AES', key='datekey')
此:
username = pgcrypto.EncryptedTextField(cipher='AES')
這:
username = pgcrypto.EncryptedTextField()
在每一種情況下,我收到了同樣的錯誤,當我做一個查詢:
文件 「/blahblahblah/python2.7/site-packages/pgcrypto/fields.py」,線路221,在as_postgresql PARAMS = lhs_params + [self.lhs.source.cipher_key] + rhs_params AttributeError的: '山口' 對象沒有屬性 '源'
現在我看這發生在類:
if django.VERSION >= (1, 7):
from django.db.models.lookups import Lookup
class EncryptedLookup (Lookup):
def as_postgresql(self, qn, connection):
lhs, lhs_params = self.process_lhs(qn, connection)
rhs, rhs_params = self.process_rhs(qn, connection)
params = lhs_params + [self.lhs.source.cipher_key] + rhs_params
rhs = connection.operators[self.lookup_name] % rhs
cipher = {
'AES': 'aes',
'Blowfish': 'bf',
}[self.lhs.source.cipher_name]
return "convert_from(decrypt(dearmor(%s), %%s, '%s'), 'utf-8')%s %s" % \
(lhs, cipher, self.lhs.source.field_cast, rhs), params
for lookup_name in ('exact', 'gt', 'gte', 'lt', 'lte'):
class_name = 'EncryptedLookup_%s' % lookup_name
lookup_class = type(class_name, (EncryptedLookup,), {'lookup_name': lookup_name})
BaseEncryptedField.register_lookup(lookup_class)
而且它似乎在lhs變量上尋找一個源代碼和一個cipher_key(我猜這代表了左邊)。
如何添加此lhs變量的來源?
是否有任何可能導致此問題的配置設置?