Skip to content

Commit

Permalink
Added support for Django 1.10 and Sphinx 2.2.10.
Browse files Browse the repository at this point in the history
Also dropped support for Django 1.7.
  • Loading branch information
jorgecarleitao committed Mar 9, 2017
1 parent 45faef2 commit 3f42f51
Show file tree
Hide file tree
Showing 10 changed files with 34 additions and 23 deletions.
17 changes: 11 additions & 6 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
language: python
python:
- "3.3"
- "3.4"

env:
- BACKEND=mysql SPHINX_VERSION=2.2.6
- BACKEND=mysql SPHINX_VERSION=2.2.10
- BACKEND=postgres SPHINX_VERSION=2.2.6
- BACKEND=postgres SPHINX_VERSION=2.2.10
- DJANGO_VERSION=1.8 BACKEND=mysql SPHINX_VERSION=2.2.10
- DJANGO_VERSION=1.8 BACKEND=mysql SPHINX_VERSION=2.2.11
- DJANGO_VERSION=1.8 BACKEND=psycopg2 SPHINX_VERSION=2.2.10
- DJANGO_VERSION=1.8 BACKEND=psycopg2 SPHINX_VERSION=2.2.11
- DJANGO_VERSION=1.10 BACKEND=mysql SPHINX_VERSION=2.2.10
- DJANGO_VERSION=1.10 BACKEND=mysql SPHINX_VERSION=2.2.11
- DJANGO_VERSION=1.10 BACKEND=psycopg2 SPHINX_VERSION=2.2.10
- DJANGO_VERSION=1.10 BACKEND=psycopg2 SPHINX_VERSION=2.2.11

install:
- sudo bash -c "$(curl -fsSL https://gist.githubusercontent.com/jorgecarleitao/ee5cede492dbe41be8a5/raw/install_sphinx.sh)" ${SPHINX_VERSION}
- pip install .
- pip install django psycopg2 pymysql
- pip install PyMySQL psycopg2
- pip install django==$DJANGO_VERSION
- pip install coveralls

script:
Expand Down
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,21 +14,23 @@ Specifically, this API allows you to:

1. Configure Sphinx with Python.
2. Index Django models in Sphinx.
3. Execute Sphinx queries (SphinxQL) using a Django-like expressions and have the
3. Execute Sphinx queries (SphinxQL) using Django-like expressions and have the
results as Django models.

Django-SphinxQL requires:

- Python 3
- mysql or postgres
- pymysql
- Django (>=1.8)
- Sphinx
- A backend (pymysql or psycopg2)

Our build matrix in Travis has 4 builds:
Our build matrix in Travis has 8 builds:

- Python 3.3 with latest Django
- Sphinx 2.2.6 and 2.2.10
- mysql and postgres backend
- Python 3.4
- Django 1.8 and 1.10
- Sphinx 2.2.10 and 2.2.11
- mysql and postgres backends

For more details, you can check the directory `tests` and `.travis.yml`.

Expand Down
2 changes: 2 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
django>=1.8
pymysql
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from setuptools import setup, find_packages

setup(name='django-sphinxql',
version='1.0.0',
version='1.1.0',
description='Sphinx search on Django',
long_description=open('README.md').read(),
author='Jorge C. Leitão',
Expand Down
7 changes: 5 additions & 2 deletions sphinxql/apps.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,12 @@ def ready(self):
it and doesn't index the models.
"""
for app in apps.get_app_configs():
module_name = app.module.__package__ + '.indexes'
try:
__import__(app.module.__package__ + '.indexes')
except ImportError:
__import__(module_name)
except ImportError as e:
if module_name not in str(e):
raise
# ignore apps without indexes.
pass

Expand Down
5 changes: 3 additions & 2 deletions sphinxql/configuration/configurators.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,8 +113,9 @@ def special_annotate(query, dict_values):

# Add the aggregates to the query
for (alias, aggregate_expr) in dict_values.items():
obj.query.add_aggregate(aggregate_expr, query.model, alias,
is_summary=False)
obj.query.add_annotation(aggregate_expr, alias, is_summary=False)
# obj.query.add_aggregate(aggregate_expr, query.model, alias,
# is_summary=False)

return obj

Expand Down
1 change: 0 additions & 1 deletion sphinxql/management/commands/start_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class Command(BaseCommand):
help = 'Interacts with search deamon.'
option_list = BaseCommand.option_list

def handle(self, **options):
self.stdout.write('Starting Sphinx')
Expand Down
1 change: 0 additions & 1 deletion sphinxql/management/commands/stop_sphinx.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@

class Command(BaseCommand):
help = 'Interacts with search deamon.'
option_list = BaseCommand.option_list

def handle(self, **options):
self.stdout.write('Stopping Sphinx')
Expand Down
4 changes: 2 additions & 2 deletions tests/foreign_relationships/indexes.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from django.db.models import F, CharField
from django.db.models.functions import Concat, Value
from django.db.models import F, CharField, Value
from django.db.models.functions import Concat
from sphinxql import indexes, fields

from .models import Document
Expand Down
4 changes: 2 additions & 2 deletions tests/settings_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@
# },
# }

INSTALLED_APPS = ('sphinxql', 'tests.query', 'tests.queryset',
'tests.indexing', 'tests.foreign_relationships')
INSTALLED_APPS = ('tests.query', 'tests.queryset',
'tests.indexing', 'tests.foreign_relationships', 'sphinxql')

SECRET_KEY = "django_tests_secret_key"

Expand Down

0 comments on commit 3f42f51

Please sign in to comment.