Skip to content

Instantly share code, notes, and snippets.

@tnir
Created May 15, 2018 05:58
Show Gist options
  • Save tnir/652de5d44b56950e7a8db350563db60b to your computer and use it in GitHub Desktop.
Save tnir/652de5d44b56950e7a8db350563db60b to your computer and use it in GitHub Desktop.
Django 2.0へのアップデート (Removed support for bytestrings編) ref: https://qiita.com/tnir/items/27a9ecd20c7c7f2e9aee
>>> from polls.models import Choice
>>> bytes_text = some_func() # => b'Just hacking'
>>> Choice(choice_text=str(bytes_text)).save()
>>> Choice.objects.filter(choice_text=bytes_text) # => NG
<QuerySet []>
>>> Choice.objects.filter(choice_text=bytes_text.decode()) # => OK
<QuerySet [<Choice: Just hacking>]>
python manage.py test
python -bb manage.py test
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment