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

Add support for the upcoming Django 3.2 #329

Merged
merged 3 commits into from Feb 15, 2021

Conversation

matthiask
Copy link
Contributor

@matthiask matthiask commented Jan 20, 2021

The CountryField uses super() in a few methods to skip CharField's methods and call methods of the CharField's superclass directly. Django 3.2 adds support for db_collation to CharField, but the CountryField doesn't need this. Since CountryField.__init__ does not call CharField.__init__, CountryField.deconstruct shouldn't call CharField.deconstruct either.

Also, Django 3.1 and django-rest-framework 3.10.x are not compatible because django-rest-framework imports the FieldDoesNotExist exception from location where it isn't available anymore in Django 3.1. Therefore, this pull request also removes this combination from the CI matrix.

Replaces #328

The CountryField uses super() in a few methods to skip CharField's methods and call methods of the CharField's superclass directly.

Django 3.2 adds support for db_collation to CharField, but the CountryField doesn't need this. Since CountryField.\_\_init__ does not call CharField.\_\_init__, CountryField.deconstruct shouldn't call CharField.deconstruct either.

Replaces SmileyChris#328
@codecov-io
Copy link

codecov-io commented Jan 20, 2021

Codecov Report

Merging #329 (b7f18ba) into master (96c188a) will not change coverage.
The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master      #329   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files           27        27           
  Lines         1385      1385           
=========================================
  Hits          1385      1385           
Impacted Files Coverage Δ
django_countries/fields.py 100.00% <100.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 96c188a...b7f18ba. Read the comment docs.

@matthiask
Copy link
Contributor Author

I have added Django 3.2a1 to the CI matrix. All tests fail without the super() change. With the change all tests pass.

@matthiask
Copy link
Contributor Author

Hmm, all tests do NOT pass, but the reason seems to be an incompatibility of Django and django-rest-framework.

DRF expects django.db.models.fields.FieldDoesNotExist to exist but the exception has been moved.
@matthiask matthiask changed the title Align super() calls in all CountryField methods Add support for the upcoming Django 3.2 Jan 23, 2021
@matthiask
Copy link
Contributor Author

Tests are passing now; I updated the description of this pull request to better reflect what it is all about.

@matthiask
Copy link
Contributor Author

I found a good workaround for the time being.

Add the following lines e.g. to your settings.py file:

if True:
    import django_countries.fields  # noqa

    django_countries.fields.CountryField.db_collation = None

@SmileyChris SmileyChris merged commit 3d96967 into SmileyChris:master Feb 15, 2021
@SmileyChris
Copy link
Owner

Thanks Matthias, I'll get a version pushed out tomorrow

@domdinicola
Copy link

is this already fixing the "db_collation" error for CountryField?

@matthiask
Copy link
Contributor Author

@domdinicola Yes.

@Mogost
Copy link

Mogost commented Mar 17, 2021

@SmileyChris Could you release a new version please?

@SmileyChris
Copy link
Owner

Released as v7.1

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.

None yet

5 participants