Skip to content

Commit d9d0d03

Browse files
committed
Remove Django 1.4, and Python 2.6 and 3.2 support
1 parent bc630e5 commit d9d0d03

File tree

6 files changed

+17
-125
lines changed

6 files changed

+17
-125
lines changed

.travis.yml

+8-20
Original file line numberDiff line numberDiff line change
@@ -4,44 +4,32 @@ sudo: false
44

55
python:
66
- 2.7
7-
- 3.2
87
- 3.3
8+
- 3.4
9+
- 3.5
910

1011
env:
11-
- DJANGO="Django>=1.4,<1.5"
1212
- DJANGO="Django>=1.6,<1.7"
1313
- DJANGO="Django>=1.7,<1.8"
1414
- DJANGO="Django>=1.8,<1.9"
15-
- DJANGO="Django>=1.9a,<1.10"
15+
- DJANGO="Django>=1.9,<1.10"
1616

1717
install:
18-
- pip install -U 'coverage<4' codecov
18+
- pip install -U coverage codecov
1919
- pip install -U $DJANGO
2020
- python -c 'from __future__ import print_function; import django; print("Django " + django.get_version())'
2121

2222
script: coverage run setup.py test
2323

2424
matrix:
2525
exclude:
26-
- python: 3.2
27-
env: DJANGO="Django>=1.4,<1.5"
28-
- python: 3.3
29-
env: DJANGO="Django>=1.4,<1.5"
30-
- python: 3.2
31-
env: DJANGO="Django>=1.9a,<1.10"
32-
- python: 3.3
33-
env: DJANGO="Django>=1.9a,<1.10"
34-
35-
include:
36-
- python: 2.6
37-
env: DJANGO="Django>=1.4,<1.5"
3826
- python: 3.4
39-
env: DJANGO="Django>=1.7,<1.8"
40-
- python: 3.4
41-
env: DJANGO="Django>=1.8,<1.9"
27+
env: DJANGO="Django>=1.6,<1.7"
4228
- python: 3.5
43-
env: DJANGO="Django>=1.8,<1.9"
29+
env: DJANGO="Django>=1.6,<1.7"
4430
- python: 3.5
31+
env: DJANGO="Django>=1.7,<1.8"
32+
- python: 3.3
4533
env: DJANGO="Django>=1.9,<1.10"
4634

4735
after_success: codecov

README.rst

+1-1
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ django-simple-history
2020

2121
django-simple-history stores Django model state on every create/update/delete.
2222

23-
This app requires Django 1.4.2, 1.6, or greater and Python 2.6 or greater.
23+
This app requires Django 1.6 or greater and Python 2.7, 3.3, or greater.
2424

2525
Getting Help
2626
------------

simple_history/admin.py

+1-5
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,8 @@
1818
from django.contrib.admin.utils import unquote
1919
except ImportError: # Django < 1.7
2020
from django.contrib.admin.util import unquote
21-
try:
22-
USER_NATURAL_KEY = settings.AUTH_USER_MODEL
23-
except AttributeError: # Django < 1.5
24-
USER_NATURAL_KEY = "auth.User"
2521

26-
USER_NATURAL_KEY = tuple(key.lower() for key in USER_NATURAL_KEY.split('.', 1))
22+
USER_NATURAL_KEY = tuple(key.lower() for key in settings.AUTH_USER_MODEL.split('.', 1))
2723

2824
SIMPLE_HISTORY_EDIT = getattr(settings, 'SIMPLE_HISTORY_EDIT', False)
2925

simple_history/manager.py

+1-4
Original file line numberDiff line numberDiff line change
@@ -20,10 +20,7 @@ def __init__(self, model, instance=None):
2020
self.instance = instance
2121

2222
def get_super_queryset(self):
23-
try:
24-
return super(HistoryManager, self).get_queryset()
25-
except AttributeError: # Django < 1.6
26-
return super(HistoryManager, self).get_query_set()
23+
return super(HistoryManager, self).get_queryset()
2724

2825
def get_queryset(self):
2926
qs = self.get_super_queryset()

simple_history/models.py

+3-89
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,11 @@
11
from __future__ import unicode_literals
22

3-
import threading
43
import copy
5-
import warnings
4+
import importlib
5+
import threading
66

7-
import django
87
from django.db import models, router
98
from django.db.models.fields.proxy import OrderWrt
10-
from django.db.models.fields.related import RelatedField
119
from django.conf import settings
1210
from django.contrib import admin
1311
from django.utils import six
@@ -20,10 +18,6 @@
2018
from django.apps import apps
2119
except ImportError: # Django < 1.7
2220
from django.db.models import get_app
23-
try:
24-
import importlib
25-
except ImportError: # Python < 2.7
26-
from django.utils import importlib
2721
try:
2822
from south.modelsinspector import add_introspection_rules
2923
except ImportError: # south not present
@@ -139,19 +133,14 @@ def copy_fields(self, model):
139133
field.__class__ = models.IntegerField
140134
if isinstance(field, models.ForeignKey):
141135
old_field = field
142-
field_arguments = {}
136+
field_arguments = {'db_constraint': False}
143137
if (getattr(old_field, 'one_to_one', False) or
144138
isinstance(old_field, models.OneToOneField)):
145139
FieldType = models.ForeignKey
146140
else:
147141
FieldType = type(old_field)
148-
if django.get_version() >= "1.6":
149-
field_arguments['db_constraint'] = False
150142
if getattr(old_field, 'to_fields', []):
151143
field_arguments['to_field'] = old_field.to_fields[0]
152-
elif (django.get_version() < "1.6" and
153-
old_field.rel.field_name != 'id'):
154-
field_arguments['to_field'] = old_field.rel.field_name
155144
if getattr(old_field, 'db_column', None):
156145
field_arguments['db_column'] = old_field.db_column
157146
field = FieldType(
@@ -261,81 +250,6 @@ def get_history_user(self, instance):
261250
return None
262251

263252

264-
class CustomForeignKeyField(models.ForeignKey):
265-
266-
def __init__(self, *args, **kwargs):
267-
warnings.warn("CustomForeignKeyField is deprecated.",
268-
DeprecationWarning)
269-
super(CustomForeignKeyField, self).__init__(*args, **kwargs)
270-
self.db_constraint = False
271-
self.generate_reverse_relation = False
272-
273-
def get_attname(self):
274-
return self.name
275-
276-
def get_one_to_one_field(self, to_field, other):
277-
# HACK This creates a new custom foreign key based on to_field,
278-
# and calls itself with that, effectively making the calls
279-
# recursive
280-
temp_field = self.__class__(to_field.rel.to._meta.object_name)
281-
for key, val in to_field.__dict__.items():
282-
if (isinstance(key, six.string_types)
283-
and not key.startswith('_')):
284-
setattr(temp_field, key, val)
285-
field = self.__class__.get_field(
286-
temp_field, other, to_field.rel.to)
287-
return field
288-
289-
def get_field(self, other, cls):
290-
# this hooks into contribute_to_class() and this is
291-
# called specifically after the class_prepared signal
292-
to_field = copy.copy(self.rel.to._meta.pk)
293-
field = self
294-
if isinstance(to_field, models.OneToOneField):
295-
field = self.get_one_to_one_field(to_field, other)
296-
elif isinstance(to_field, models.AutoField):
297-
field.__class__ = convert_auto_field(to_field)
298-
else:
299-
field.__class__ = to_field.__class__
300-
excluded_prefixes = ("_", "__")
301-
excluded_attributes = (
302-
"rel",
303-
"creation_counter",
304-
"validators",
305-
"error_messages",
306-
"attname",
307-
"column",
308-
"help_text",
309-
"name",
310-
"model",
311-
"unique_for_year",
312-
"unique_for_date",
313-
"unique_for_month",
314-
"db_tablespace",
315-
"db_index",
316-
"db_column",
317-
"default",
318-
"auto_created",
319-
"null",
320-
"blank",
321-
)
322-
for key, val in to_field.__dict__.items():
323-
if (isinstance(key, six.string_types)
324-
and not key.startswith(excluded_prefixes)
325-
and key not in excluded_attributes):
326-
setattr(field, key, val)
327-
return field
328-
329-
def do_related_class(self, other, cls):
330-
field = self.get_field(other, cls)
331-
transform_field(field)
332-
field.rel = None
333-
334-
def contribute_to_class(self, cls, name):
335-
# HACK: remove annoying descriptor (don't super())
336-
RelatedField.contribute_to_class(self, cls, name)
337-
338-
339253
def transform_field(field):
340254
"""Customize field appropriately for use in historical model"""
341255
field.name = field.attname

tox.ini

+3-6
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
[tox]
22
envlist =
3-
py{26,27}-django14,
4-
py{26,27,32,33}-django16,
5-
py{27,32,33,34}-django17,
6-
py{27,32,33,34,35}-django18,
3+
py{27,33}-django16,
4+
py{27,33,34}-django17,
5+
py{27,33,34,35}-django18,
76
py{27,34,35}-django19,
87
py{27,34,35}-djangotrunk,
98
docs, flake8
@@ -30,8 +29,6 @@ commands = sphinx-build -W -b html -d {envtmpdir}/doctrees . {envtmpdir}/html
3029
[testenv]
3130
deps =
3231
coverage
33-
py26: unittest2
34-
django14: Django>=1.4,<1.5
3532
django16: Django>=1.6,<1.7
3633
django17: Django>=1.7,<1.8
3734
django18: Django>=1.8,<1.9

0 commit comments

Comments
 (0)