Django queryset.extra() is used here to add decryption sql to query.

def get_queryset(self, *args, **kwargs):
        """Django queryset.extra() is used here to add decryption sql to query."""
        select_sql = {}
        encrypted_fields = []
        for f in self.model._meta.get_fields_with_model():
            field = f[0]
            if isinstance(field, PGPMixin):
                select_sql[field.name] = self.get_decrypt_sql(field).format(
                    field.model._meta.db_table,
                    field.name,
                    settings.PGPFIELDS_PRIVATE_KEY,
                )
                encrypted_fields.append(field.name)
        return super(PGPEncryptedManager, self).get_queryset(
            *args, **kwargs).defer(*encrypted_fields).extra(select=select_sql)