#29632: After migrating a Django project from Python 2 to 3, db migration of
django.contrib.sites fails with "TypeError: attribute name must be string,
not 'bytes'"
-------------------------------------+-------------------------------------
Reporter: Florian Mayer | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: master
Severity: Normal | Resolution: needsinfo
Keywords: migration, unicode, | Triage Stage:
bytestring, TypeError | Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0
Easy pickings: 1 | UI/UX: 0
-------------------------------------+-------------------------------------
Comment (by Florian Mayer):
Found the cause: The project template I've used,
[https://github.com/pydanny/cookiecutter-django cookiecutter-django],
generated a separate 'sites' app in my project directory. That one had a
stray bytestring b'objects' in its migrations. Side note, cookiecutter-
django was good enough to insert an [http://cookiecutter-
django.readthedocs.io/en/latest/faq.html#why-is-there-a-django-contrib-
sites-directory-in-cookiecutter-django explanation] for the presence of
this 'sites' app.
To conclude, I'd like to close this issue with the suggestion to include a
Django warning in either django.db.models.base.ModelBase
[https://github.com/django/django/blob/master/django/db/models/base.py#L139
here] if `obj_name` is a bytestring, or as suggested originally in
django.db.models.manager
[https://github.com/django/django/blob/master/django/db/models/manager.py#L113
here] if `name` is a bytestring. Would such a warning make sense?
--
Ticket URL: <https://code.djangoproject.com/ticket/29632#comment:5>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
--
You received this message because you are subscribed to the Google Groups
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/066.f8ad5cd22bdd5e6e3220bc6679475e08%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.