Skip to content
This repository was archived by the owner on Apr 5, 2020. It is now read-only.
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 3 additions & 10 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,10 @@ language: python
sudo: false
env:
- TOX_ENV=py27-flake8
- TOX_ENV=py34-flake8
- TOX_ENV=py27-dj17
- TOX_ENV=py27-dj18
- TOX_ENV=py27-dj19
- TOX_ENV=py27-dj110
- TOX_ENV=py36-flake8
- TOX_ENV=py27-dj111
- TOX_ENV=py34-dj17
- TOX_ENV=py34-dj18
- TOX_ENV=py34-dj19
- TOX_ENV=py34-dj110
- TOX_ENV=py34-dj111
- TOX_ENV=py36-dj111
- TOX_ENV=py36-dj20
install:
- pip install -r requirements-test.txt
script:
Expand Down
2 changes: 1 addition & 1 deletion ajax_select/fields.py
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ def autoselect_fields_check_can_add(form, model, user):
for name, form_field in form.declared_fields.items():
if isinstance(form_field, (AutoCompleteSelectMultipleField, AutoCompleteSelectField)):
db_field = model._meta.get_field(name)
form_field.check_can_add(user, db_field.rel.to)
form_field.check_can_add(user, db_field.remote_field.model)


def make_plugin_options(lookup, channel_name, widget_plugin_options, initial):
Expand Down
4 changes: 2 additions & 2 deletions ajax_select/lookup_channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def get_objects(self, ids):
list: list of Model objects
"""
# Inherited models have a OneToOneField (rather than eg AutoField)
if self.model._meta.pk.rel is not None:
if self.model._meta.pk.remote_field is not None:
# Use the type of the field being referenced
pk_type = self.model._meta.pk.rel.field.to_python
pk_type = self.model._meta.pk.remote_field.field.to_python
else:
pk_type = self.model._meta.pk.to_python

Expand Down
2 changes: 1 addition & 1 deletion example/example/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
####################################
)

MIDDLEWARE_CLASSES = (
MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware'
Expand Down
2 changes: 1 addition & 1 deletion tests/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ class Book(models.Model):

""" Book has no admin, its an inline in the Author admin"""

author = models.ForeignKey(Author, null=True)
author = models.ForeignKey(Author, null=True, on_delete=models.CASCADE)
name = models.CharField(max_length=50)
mentions_persons = models.ManyToManyField(Person, help_text="MENTIONS PERSONS HELP TEXT")

Expand Down
2 changes: 1 addition & 1 deletion tests/settings.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
"tests"
]
SITE_ID = 1
MIDDLEWARE_CLASSES = (
MIDDLEWARE = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware'
Expand Down
9 changes: 2 additions & 7 deletions tests/test_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,14 @@
should be unit tested in test_fields.py
"""
from __future__ import unicode_literals
import django
from django.forms.models import ModelForm
from django.test import TestCase, Client
from django.core.urlresolvers import reverse
from django.urls import reverse
from django.contrib.auth.models import User

from tests.models import Book, Author, Person
from ajax_select import fields

# Other versions will autoload
if django.VERSION[1] < 7:
from tests import lookups # noqa

# --------------- setup ----------------------------------- #


Expand Down Expand Up @@ -48,7 +43,7 @@ def test_render_no_data(self):
def _make_instance(self):
author = Author.objects.create(name="author")
book = Book.objects.create(name="book", author=author)
book.mentions_persons = [Person.objects.create(name='person')]
book.mentions_persons.set([Person.objects.create(name='person')])
return book

def _book_data(self, book):
Expand Down
2 changes: 1 addition & 1 deletion tests/urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@

urlpatterns = [
url(r'^ajax_lookups/', include(ajax_select_urls)),
url(r'^admin/', include(admin.site.urls)),
url(r'^admin/', include((admin.site.get_urls(), 'admin'), namespace='admin')),
] + static(settings.STATIC_URL, document_root=settings.STATIC_ROOT)
11 changes: 4 additions & 7 deletions tox.ini
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@
;
[tox]
envlist =
{py27,py34}-flake8,
{py27,py34}-{dj17,dj18,dj19,dj110,dj111}
{py27,py36}-flake8,
py27-dj111,py36-dj111,py36-dj20


[testenv]
Expand All @@ -16,19 +16,16 @@ setenv =
PYTHONPATH = {toxinidir}:{toxinidir}/ajax_select:{toxinidir}/tests
commands = django-admin.py test tests
deps =
dj17: Django>=1.7.11,<1.8
dj18: Django>=1.8.18,<1.9
dj19: Django>=1.9.13,<1.10
dj110: Django>=1.10.8,<1.11
dj111: Django>=1.11.5,<1.12
dj20: Django>=2.0rc1,<2.1
; djmaster: https://github.com/django/django/zipball/master

[testenv:py27-flake8]
deps =
flake8
commands = flake8 ajax_select tests example

[testenv:py34-flake8]
[testenv:py36-flake8]
deps =
flake8
commands = flake8 ajax_select tests example
Expand Down