2012-01-09 5 views
0

У меня есть требование, чтобы я зашифровал некоторые поля в таблице. Я использую Django 1.3.1 и postgres 9.1. Я имею в виду это приложение Джанго полей: -Шифровать DateField в моделях django?

https://github.com/svetlyak40wt/django-fields/blob/master/src/django_fields/fields.py

Вот мой код: -

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) 

Он хранит все в зашифрованном виде в базе данных, кроме date_of_birth.It выдает эту ошибку

Traceback: Файл "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py" в get_response 111. ответ = обратного вызова (запрос * callback_args ** callba ck_kwargs) Файл «/home/user/slave/old_careprep/CPMS-Source/careprep/../careprep/utilities/decorators.py» in _dec 14. return view_func (request, * args, ** kwargs) Файл "/home/user/slave/old_careprep/CPMS-Source/careprep/../careprep/visit/views.py" в настройке 202. patient.save() Файл "/usr/local/lib/python2.7 /dist-packages/django/db/models/base.py "in save 460. self.save_base (using = using, force_insert = force_insert, force_update = force_update) Файл" /usr/local/lib/python2.7/ dist-packages/django/db/models/base.py "в save_base 553. result = manager._insert (значения, return_id = update_pk, using = using) Файл" /usr/local/lib/python2.7/dist -пакеты/django/db/models/manager.py "в _insert 195. return insert_query (self.model, values, ** kwargs) Файл «/usr/local/lib/python2.7/dist-packages/django/db/models/query.py» в insert_query 1436. return query.get_compiler (using = using) .execute_sql (return_id) Файл «/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py» в execute_sql 791. cursor = super (SQLInsertCompiler, self) .execute_sql (None) Файл «/usr/local/lib/python2.7/dist-packages/django/db/models/sql/compiler.py» в execute_sql 735. cursor.execute (sql, params) Файл «/usr/local/lib/python2.7/dist-packages/django/db/backends/util.py» в исполнении 34. return self.cursor.execute (sql, params) Файл «/usr/local/lib/python2.7/dist-packages/django/db/backends/ postgresql_psycopg2/base.py "в казнить 44. обратный self.cursor.execute (запрос, арг)

Тип исключения: DatabaseError в/посещение/установки/ Исключение Значение: неверный входной синтаксис для типа дата:" $ AES $ 55403376ed906e119b0f7779554fbb51 " LINE 1: ... L, NULL, '$ AES $ 0452edae035cc33c4084e7b0fb39edd7', '$ AES $ 5540 ... ^ Помощь будет оценена.

Благодаря

ответ

0

я понял, что я использовал DateField раньше, если я конвертировать DateField в CharField, а затем применить EncryptedCharField решает мою проблему

Смежные вопросы