Function pgp_sym_encrypt(numeric, unknown) does not exist

2.5k Views Asked by At

I am using https://github.com/incuna/django-pgcrypto-fields for pgcrypto in my Django project. It's working fine with inserting, updating fields. But when I am trying something like

MyTable.objects.filter(some_code=somecode).update(
                    some_value=some_price * F('some_units'),
                    updated_on=datetime.now()
                )

Its throwing me psycopg2.errors.UndefinedFunction: function pgp_sym_encrypt(numeric, unknown) does not exist

Any help would be great. Thanks :)

1

There are 1 best solutions below

2
On

To use pgcrypto functions, the pgcrypto extension must be created in the database.

$  psql mydbname -c 'CREATE EXTENSION pgcrypto;'
CREATE EXTENSION
$  psql mydbname -c '\dx'
                            List of installed extensions
   Name    | Version |   Schema   |                   Description                   
-----------+---------+------------+-------------------------------------------------
 pgcrypto  | 1.3     | public     | cryptographic functions
...