jazzband / django-smart-selects

chained and grouped selects for django forms
https://django-smart-selects.readthedocs.io/
BSD 3-Clause "New" or "Revised" License
1.12k stars 352 forks source link

fix force text enconding support for django 4 #341

Closed diego1996 closed 2 years ago

manelclos commented 2 years ago

Hi @diego1996 could you please remove the .idea files?

diego1996 commented 2 years ago

Hi @diego1996 can you please remove the .idea files?

Yeah, I hadn't realised.

codecov[bot] commented 2 years ago

Codecov Report

Merging #341 (dd911dd) into master (2cff847) will decrease coverage by 4.85%. The diff coverage is 100.00%.

@@            Coverage Diff             @@
##           master     #341      +/-   ##
==========================================
- Coverage   80.42%   75.57%   -4.86%     
==========================================
  Files           8        8              
  Lines         470      479       +9     
  Branches       68       81      +13     
==========================================
- Hits          378      362      -16     
- Misses         60       82      +22     
- Partials       32       35       +3     
Impacted Files Coverage Δ
smart_selects/form_fields.py 71.69% <100.00%> (-10.31%) :arrow_down:
smart_selects/utils.py 84.61% <100.00%> (-15.39%) :arrow_down:
smart_selects/widgets.py 63.53% <100.00%> (-2.76%) :arrow_down:
smart_selects/views.py 74.02% <0.00%> (-9.10%) :arrow_down:

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 2cff847...dd911dd. Read the comment docs.

manelclos commented 2 years ago

Hi @diego1996,

I had no problems when including Django 4.0 in the tests matrix, see this PR for tests results: https://github.com/jazzband/django-smart-selects/pull/322

Also, Django 4.0 is deprecating force_text, not force_str: https://docs.djangoproject.com/en/4.0/releases/4.0/#features-removed-in-4-0

Can you please elaborate on why this PR is needed?

luzdealba commented 2 years ago

Thanks for this patch, @diego1996!

This PR fixed a Django v4 deprecation issue for me; and it's also written in try/except block that keeps v3 backwards compatibility.

You should consider merging it to master.

Best.

Blind-Watchmaker commented 2 years ago

What is the status on this issue? I'm trying to migrate my project to Django 4.0 and django-smart-selects is the only package that is holding me back.

from django.utils.encoding import force_text
ImportError: cannot import name 'force_text' from 'django.utils.encoding'
manelclos commented 2 years ago

@Blind-Watchmaker according to test results Django main worked but all other versions failed. Patch needs to be adjusted.

manelclos commented 2 years ago

@diego1996 can you please fix the PR?

manelclos commented 2 years ago

@Blind-Watchmaker django-smart-selects 1.6.0 is out and features django 4.0 support. Please let me know if you test it. Thanks!

https://pypi.org/project/django-smart-selects/

diego1996 commented 2 years ago

Hola chicos, perdon lo tarde, recien lo veo, que bueno que ya se halla solucionado el problema.

diego1996 commented 2 years ago

Voy a declinar este PR