Skip to content

Commit 2237710

Browse files
authored
Merge pull request justinmayer#16 from azmeuk/django-deprecations
Django 1.10 compatibility
2 parents a16fd5e + 2d26169 commit 2237710

File tree

4 files changed

+7
-5
lines changed

4 files changed

+7
-5
lines changed

AUTHORS.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,4 +31,5 @@ generally made django-autoslug better:
3131
* kane-c
3232
* Julien Dubiel
3333
* Tony Shtarev
34+
* Éloi Rivard
3435
* Your Name Here ;)

CHANGELOG.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ Version 1.9.4-dev
77
New features:
88

99
- Add `manager_name` kwarg to enable using custom managers from abstract models.
10+
- Django 1.10 compatibility.
1011

1112
Version 1.9.3
1213
-------------

autoslug/tests/models.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from django.db.models import Model, CharField, DateField, BooleanField, ForeignKey, Manager
1+
from django.db.models import Model, CharField, DateField, BooleanField, ForeignKey, Manager, CASCADE
22

33

44
# this app
@@ -18,7 +18,7 @@ class ModelWithUniqueSlug(Model):
1818

1919
class ModelWithUniqueSlugFK(Model):
2020
name = CharField(max_length=200)
21-
simple_model = ForeignKey(SimpleModel)
21+
simple_model = ForeignKey(SimpleModel, on_delete=CASCADE)
2222
slug = AutoSlugField(populate_from='name', unique_with='simple_model__name')
2323

2424

@@ -138,7 +138,7 @@ class ModelWithSlugSpaceShared(SharedSlugSpace):
138138

139139
class ModelWithUniqueSlugFKNull(Model):
140140
name = CharField(max_length=200)
141-
simple_model = ForeignKey(SimpleModel, null=True, blank=True, default=None)
141+
simple_model = ForeignKey(SimpleModel, null=True, blank=True, default=None, on_delete=CASCADE)
142142
slug = AutoSlugField(populate_from='name', unique_with='simple_model')
143143

144144

@@ -169,4 +169,4 @@ def delete(self, using=None):
169169

170170
class NonDeletableModelWithUniqueSlug(AbstractModelWithCustomManager):
171171
name = CharField(max_length=200)
172-
slug = AutoSlugField(populate_from='name', unique=True, manager_name='all_objects')
172+
slug = AutoSlugField(populate_from='name', unique=True, manager_name='all_objects')

autoslug/utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,7 +116,7 @@ def get_uniqueness_lookups(field, instance, unique_with):
116116
value = getattr(instance, field_name)
117117
if not value:
118118
if other_field.blank:
119-
field_object, model, direct, m2m = instance._meta.get_field_by_name(field_name)
119+
field_object = instance._meta.get_field(field_name)
120120
if isinstance(field_object, ForeignKey):
121121
lookup = '%s__isnull' % field_name
122122
yield lookup, True

0 commit comments

Comments
 (0)