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

Remove deprecated warning with django 3 #73

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
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
6 changes: 3 additions & 3 deletions multisite/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,7 +142,7 @@ class NotCanonicalAliasManager(models.Manager):

def get_queryset(self):
qset = super(NotCanonicalAliasManager, self).get_queryset()
return qset.filter(is_canonical__isnull=True)
return qset.filter(is_canonical=False)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kutera if we don't set a default on the field class then we don't need this change

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This change avoid deprecated warning and error in future django release.
In django 3.1 See https://docs.djangoproject.com/en/dev/releases/3.1/#deprecated-features-3-1
"The undocumented usage of the isnull lookup with non-boolean values as the right-hand side will no longer be allowed."

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kutera, I had missed that, thanks for pointing this out.



def validate_true_or_none(value):
Expand Down Expand Up @@ -170,9 +170,9 @@ class Alias(models.Model):
site = models.ForeignKey(
Site, related_name='aliases', on_delete=models.CASCADE
)
is_canonical = models.NullBooleanField(
is_canonical = models.BooleanField(
_('is canonical?'),
default=None, editable=False,
default=False, editable=False,
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@kutera, I suggest removing default=False since the default value of BooleanField is None when default= isn’t defined. Then you don't need the change in get_queryset.

validators=[validate_true_or_none],
help_text=_('Does this domain name match the one in site?'),
)
Expand Down