Django models 在django模型中加密日期字段?
我需要对表中的一些字段进行加密。 我正在使用Django 1.3.1和postgres 9.1。我指的是这个应用程序django字段:- 这是我的密码:-Django models 在django模型中加密日期字段?,django-models,Django Models,我需要对表中的一些字段进行加密。 我正在使用Django 1.3.1和postgres 9.1。我指的是这个应用程序django字段:- 这是我的密码:- patient_type = EncryptedCharField(max_length=80, choices=CHOICES.PATIENT_TYPES) date_of_birth = EncryptedDateField(null=True, blank=True) gender = EncryptedCharField(max_l
patient_type = EncryptedCharField(max_length=80, choices=CHOICES.PATIENT_TYPES)
date_of_birth = EncryptedDateField(null=True, blank=True)
gender = EncryptedCharField(max_length=1024, choices=CHOICES.GENDERS, blank=True)
contact_phone = EncryptedCharField(max_length=1024, blank=True)
security_question = models.ForeignKey(SecurityQuestion, null=True, blank=True)
security_answer = EncryptedCharField(max_length=1024, null=True, blank=True)
它以加密形式在数据库中存储除出生日期之外的所有内容。它抛出此错误
回溯:
get_响应中的文件“/usr/local/lib/python2.7/dist packages/django/core/handlers/base.py”
111响应=回调(请求,*回调参数,**回调参数)
文件“/home/user/slave/old_-careprep/CPMS-Source/carepep/。/carepep/utilities/decorators.py”
14返回视图功能(请求,*args,**kwargs)
设置中的文件“/home/user/slave/old_careprep/CPMS Source/carepep/。/carepep/visit/views.py”
202病人,救命
保存中的文件“/usr/local/lib/python2.7/dist packages/django/db/models/base.py”
460self.save_base(使用=使用,强制插入=强制插入,强制更新=强制更新)
save_base中的文件“/usr/local/lib/python2.7/dist packages/django/db/models/base.py”
553结果=管理器。\u插入(值,返回\u id=update\u pk,using=using)
插入文件“/usr/local/lib/python2.7/dist packages/django/db/models/manager.py”
195返回insert_查询(self.model,value,**kwargs)
insert\u查询中的文件“/usr/local/lib/python2.7/dist packages/django/db/models/query.py”
1436return query.get\u编译器(using=using).execute\u sql(return\u id)
execute_sql中的文件“/usr/local/lib/python2.7/dist packages/django/db/models/sql/compiler.py”
791cursor=super(SQLInsertCompiler,self)。执行\u sql(无)
execute_sql中的文件“/usr/local/lib/python2.7/dist packages/django/db/models/sql/compiler.py”
735cursor.execute(sql,params)
execute中的文件“/usr/local/lib/python2.7/dist packages/django/db/backends/util.py”
34返回self.cursor.execute(sql,params)
execute中的文件“/usr/local/lib/python2.7/dist packages/django/db/backends/postgresql_psycopg2/base.py”
44返回self.cursor.execute(查询,参数)
异常类型:数据库错误位于/visit/setup/
异常值:类型日期的输入语法无效:$AES$55403376ED906E119B0F77779554FBB51
第1行:…L,NULL,'$AES$0452edae035cc33c4084e7b0fb39edd7','$AES$5540。。。
^
我们将不胜感激
感谢我意识到我之前使用的是DateField,如果我将DateField转换为CharField,然后应用EncryptedCharField,它就解决了我的问题