Skip to content

Commit

Permalink
Merge pull request #16 from azmeuk/django-deprecations
Browse files Browse the repository at this point in the history
Django 1.10 compatibility
  • Loading branch information
neithere authored Oct 16, 2016
2 parents a16fd5e + 2d26169 commit 2237710
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions AUTHORS.rst
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ generally made django-autoslug better:
* kane-c
* Julien Dubiel
* Tony Shtarev
* Éloi Rivard
* Your Name Here ;)
1 change: 1 addition & 0 deletions CHANGELOG.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ Version 1.9.4-dev
New features:

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

Version 1.9.3
-------------
Expand Down
8 changes: 4 additions & 4 deletions autoslug/tests/models.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
from django.db.models import Model, CharField, DateField, BooleanField, ForeignKey, Manager
from django.db.models import Model, CharField, DateField, BooleanField, ForeignKey, Manager, CASCADE


# this app
Expand All @@ -18,7 +18,7 @@ class ModelWithUniqueSlug(Model):

class ModelWithUniqueSlugFK(Model):
name = CharField(max_length=200)
simple_model = ForeignKey(SimpleModel)
simple_model = ForeignKey(SimpleModel, on_delete=CASCADE)
slug = AutoSlugField(populate_from='name', unique_with='simple_model__name')


Expand Down Expand Up @@ -138,7 +138,7 @@ class ModelWithSlugSpaceShared(SharedSlugSpace):

class ModelWithUniqueSlugFKNull(Model):
name = CharField(max_length=200)
simple_model = ForeignKey(SimpleModel, null=True, blank=True, default=None)
simple_model = ForeignKey(SimpleModel, null=True, blank=True, default=None, on_delete=CASCADE)
slug = AutoSlugField(populate_from='name', unique_with='simple_model')


Expand Down Expand Up @@ -169,4 +169,4 @@ def delete(self, using=None):

class NonDeletableModelWithUniqueSlug(AbstractModelWithCustomManager):
name = CharField(max_length=200)
slug = AutoSlugField(populate_from='name', unique=True, manager_name='all_objects')
slug = AutoSlugField(populate_from='name', unique=True, manager_name='all_objects')
2 changes: 1 addition & 1 deletion autoslug/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ def get_uniqueness_lookups(field, instance, unique_with):
value = getattr(instance, field_name)
if not value:
if other_field.blank:
field_object, model, direct, m2m = instance._meta.get_field_by_name(field_name)
field_object = instance._meta.get_field(field_name)
if isinstance(field_object, ForeignKey):
lookup = '%s__isnull' % field_name
yield lookup, True
Expand Down

0 comments on commit 2237710

Please sign in to comment.