Skip to content

Commit df4f675

Browse files
authored
Merge pull request #259 from crucialfelix/feature/fix-six-py2-import
Feature/fix six py2 import
2 parents cc5b136 + 2b64357 commit df4f675

File tree

4 files changed

+32
-30
lines changed

4 files changed

+32
-30
lines changed

ajax_select/fields.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22

33
import json
44
import sys
5-
from six import text_type
5+
6+
from ajax_select.registry import registry
67
from django import forms
78
from django.conf import settings
89
from django.contrib.contenttypes.models import ContentType
@@ -14,7 +15,11 @@
1415
from django.utils.module_loading import import_string
1516
from django.utils.safestring import mark_safe
1617

17-
from ajax_select.registry import registry
18+
try:
19+
from six import text_type
20+
except ImportError:
21+
from django.utils.six import text_type
22+
1823

1924
if sys.version_info.major >= 3:
2025
from django.utils.translation import gettext as _

ajax_select/static/ajax_select/css/ajax_select.css

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,19 +6,19 @@
66
padding: 0.25em 0;
77
}
88
form .aligned .results_on_deck {
9-
padding-left: 38px;
10-
margin-left: 7em;
9+
padding-left: 14px;
10+
margin-left: 160px;
1111
}
1212
.results_on_deck > div {
13-
margin-bottom: 0.5em;
13+
margin: 0.5em 0;
1414
}
1515
.ui-autocomplete-loading {
16-
background: url('../images/loading-indicator.gif') no-repeat;
16+
background: url("../images/loading-indicator.gif") no-repeat;
1717
background-origin: content-box;
1818
background-position: right;
1919
}
2020
ul.ui-autocomplete {
21-
/*
21+
/*
2222
this is the dropdown menu.
2323
2424
if max-width is not set and you are using django-admin

example/example/lookups.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
11
from __future__ import unicode_literals
22

3+
import ajax_select
4+
from ajax_select import LookupChannel
35
from django.db.models import Q
46
from django.utils.html import escape
5-
from django.utils.six import text_type
7+
68
from example.models import Group, Person, Song
79

8-
import ajax_select
9-
from ajax_select import LookupChannel
10+
try:
11+
from six import text_type
12+
except ImportError:
13+
from django.utils.six import text_type
1014

1115

1216
class PersonLookup(LookupChannel):

example/example/settings.py

Lines changed: 13 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,6 @@
6363

6464

6565
DEBUG = True
66-
TEMPLATE_DEBUG = DEBUG
6766

6867
ADMINS = (
6968
# ('Your Name', '[email protected]'),
@@ -122,32 +121,26 @@
122121

123122
ROOT_URLCONF = 'example.urls'
124123

125-
# Django < 1.8
126-
TEMPLATE_DIRS = (
127-
# Put strings here, like "/home/html/django_templates"
128-
# Always use forward slashes, even on Windows.
129-
# Don't forget to use absolute paths, not relative paths.
130-
)
124+
ROOT_URLCONF = "example.urls"
131125

132-
# Django >= 1.8
133126
TEMPLATES = [
134127
{
135-
'BACKEND': 'django.template.backends.django.DjangoTemplates',
136-
'DIRS': [
128+
"BACKEND": "django.template.backends.django.DjangoTemplates",
129+
"DIRS": [
137130
# insert your TEMPLATE_DIRS here
138131
],
139-
'APP_DIRS': True,
140-
'OPTIONS': {
141-
'context_processors': [
132+
"APP_DIRS": True,
133+
"OPTIONS": {
134+
"context_processors": [
142135
# Insert your TEMPLATE_CONTEXT_PROCESSORS here or use this
143136
# list if you haven't customized them:
144-
'django.contrib.auth.context_processors.auth',
145-
'django.template.context_processors.debug',
146-
'django.template.context_processors.i18n',
147-
'django.template.context_processors.media',
148-
'django.template.context_processors.static',
149-
'django.template.context_processors.tz',
150-
'django.contrib.messages.context_processors.messages',
137+
"django.contrib.auth.context_processors.auth",
138+
"django.template.context_processors.debug",
139+
"django.template.context_processors.i18n",
140+
"django.template.context_processors.media",
141+
"django.template.context_processors.static",
142+
"django.template.context_processors.tz",
143+
"django.contrib.messages.context_processors.messages",
151144
],
152145
},
153146
# TEMPLATE_LOADERS = (

0 commit comments

Comments
 (0)