If you are updating and older Django project and getting an error in this form:
TypeError: attribute name must be string, not 'bytes'
It's likely that you have existing migrations in your code base that have legacy byte strings. I found them in two places. In the related_name as shown below
('article', models.ForeignKey(related_name=b'author', to='core.Article', on_delete=models.CASCADE, null=True)),
And also in migrations where models had Choice fields. If you remove the byte strings from your migrations you should be
good to go. Easiest way is to use a good code editor like VSCode and use the Edit/Find in Files
feature to find all
instances of b'
and replace with a '
... be prudent and visit each file for a visual inspection, do the find/replace
one file at a time.
This article might be helpful if you want to clean up and reset you migrations after getting everything updated.