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

Conversation

kutera
Copy link

@kutera kutera commented Oct 31, 2020

Hello,
On Django 3 a warning appears. Here a small commit with correction to avoid it.

I noticed a regression with tldextract==3.0.2 :
middelware.py 245: tldextract.TLDExtract(cache_file=self.psl_cache)
The cache_file option is replaced by cache_dir.

My work around was to add tldextract==2.2.3 in the requirements.

Best Regards

@damon-rand
Copy link

Thank you for the contribution @kutera

Copy link

@chewthemonkey chewthemonkey left a comment

Choose a reason for hiding this comment

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

Thanks for the PR.

I think we will need to remove the custom validator validate_true_or_none.

Do we also need a data migration to update all the existing values of null/None to False?

_('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.

@@ -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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants