Skip to content

Commit

Permalink
Small doc and test tweaks
Browse files Browse the repository at this point in the history
  • Loading branch information
dcwatson committed Sep 3, 2014
1 parent e604223 commit db78899
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 6 deletions.
14 changes: 8 additions & 6 deletions docs/index.rst
Original file line number Diff line number Diff line change
@@ -1,8 +1,3 @@
.. django-pgcrypto documentation master file, created by
sphinx-quickstart on Mon May 12 23:14:40 2014.
You can adapt this file completely to your liking, but it should at least
contain the root `toctree` directive.
Welcome to django-pgcrypto's documentation!
===========================================

Expand Down Expand Up @@ -32,7 +27,14 @@ If not specified when creating the field (as in the ``date_hired`` field above),
The default key to use for encryption.


Contents:
Querying
--------

With Django 1.7, it is possible to filter on encrypted fields as you would normal fields via ``exact``, ``gt``, ``gte``,
``lt``, and ``lte`` lookups. For example, querying the model above is possible like so::

Employee.objects.filter(date_hired__gt='1981-01-01', salary__lt=60000)


.. toctree::
:maxdepth: 2
Expand Down
3 changes: 3 additions & 0 deletions tests/core/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -75,3 +75,6 @@ def test_date_lookups(self):
self.assertEqual(Employee.objects.filter(date_hired='1999-01-23').count(), 1)
self.assertEqual(Employee.objects.filter(date_hired__gte='1999-01-01').count(), 1)
self.assertEqual(Employee.objects.filter(date_hired__gt='1981-01-01').count(), 2)

def test_multi_lookups(self):
self.assertEqual(Employee.objects.filter(date_hired__gt='1981-01-01', salary__lt=60000).count(), 1)
1 change: 1 addition & 0 deletions tests/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
Django>=1.7
psycopg2
pycrypto
4 changes: 4 additions & 0 deletions tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,10 @@
'core',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
)

ROOT_URLCONF = 'urls'

DATABASES = {
Expand Down

0 comments on commit db78899

Please sign in to comment.