lokhman / django-better-choices

Better choices library for Django web framework
MIT License
7 stars 1 forks source link

Fix bug with deepcopy #1

Closed browniebroke closed 3 years ago

browniebroke commented 3 years ago

Hello there 👋

So we have an issue with using django-better-choices in DRF serializers. The choices end up as empty strings in fields where the serializer is instantiated.

From a quick debugging session, I've tracked down to the fact that REST framework deep-copies the fields.

I've written a minimal test case by calling copy.deepcopy on a choice value and the result returns empty. It works fine if the value is casted to a string before being passed to deepcopy: copy.deepcopy(str(CHOICE.VALUE))

codecov[bot] commented 3 years ago

Codecov Report

Merging #1 (deeeda8) into master (7a32d4e) will not change coverage. The diff coverage is 100.00%.

Impacted file tree graph

@@            Coverage Diff            @@
##            master        #1   +/-   ##
=========================================
  Coverage   100.00%   100.00%           
=========================================
  Files            3         3           
  Lines          315       321    +6     
=========================================
+ Hits           315       321    +6     
Impacted Files Coverage Δ
django_better_choices/__init__.py 100.00% <100.00%> (ø)
tests.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 7a32d4e...deeeda8. Read the comment docs.