Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Django 1.10 compatibility #16

Merged
merged 3 commits into from
Oct 16, 2016
Merged
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
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