[Django] #24741: migration error

45 views
Skip to first unread message

Django

unread,
May 3, 2015, 3:24:19 PM5/3/15
to django-...@googlegroups.com
#24741: migration error
----------------------------+--------------------
Reporter: drakkan | Owner: nobody
Type: Bug | Status: new
Component: Migrations | Version: 1.8
Severity: Normal | Keywords:
Triage Stage: Unreviewed | Has patch: 0
Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------
If there are no migrations to apply I get this error:


{{{
Synchronizing apps without migrations:
Creating tables...
Running deferred SQL...
Installing custom SQL...
Running migrations:
No migrations to apply.
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/nicola/django18/lib/python2.7/site-
packages/Django-1.8.1-py2.7.egg/django/core/management/__init__.py", line
338, in execute_from_command_line
utility.execute()
File "/home/nicola/django18/lib/python2.7/site-
packages/Django-1.8.1-py2.7.egg/django/core/management/__init__.py", line
330, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/home/nicola/django18/lib/python2.7/site-
packages/Django-1.8.1-py2.7.egg/django/core/management/base.py", line 390,
in run_from_argv
self.execute(*args, **cmd_options)
File "/home/nicola/django18/lib/python2.7/site-
packages/Django-1.8.1-py2.7.egg/django/core/management/base.py", line 441,
in execute
output = self.handle(*args, **options)
File "/home/nicola/django18/lib/python2.7/site-
packages/Django-1.8.1-py2.7.egg/django/core/management/commands/migrate.py",
line 207, in handle
changes = autodetector.changes(graph=executor.loader.graph)
File "/home/nicola/django18/lib/python2.7/site-
packages/Django-1.8.1-py2.7.egg/django/db/migrations/autodetector.py",
line 43, in changes
changes = self._detect_changes(convert_apps, graph)
File "/home/nicola/django18/lib/python2.7/site-
packages/Django-1.8.1-py2.7.egg/django/db/migrations/autodetector.py",
line 186, in _detect_changes
self.generate_altered_fields()
File "/home/nicola/django18/lib/python2.7/site-
packages/Django-1.8.1-py2.7.egg/django/db/migrations/autodetector.py",
line 850, in generate_altered_fields
if old_field_dec != new_field_dec:
File "/home/nicola/django18/lib/python2.7/site-
packages/Django-1.8.1-py2.7.egg/django/utils/functional.py", line 165, in
__eq__
return self.__cast() == other
File "/home/nicola/django18/lib/python2.7/site-
packages/Django-1.8.1-py2.7.egg/django/utils/functional.py", line 153, in
__cast
return self.__text_cast()
File "/home/nicola/django18/lib/python2.7/site-
packages/Django-1.8.1-py2.7.egg/django/utils/functional.py", line 141, in
__text_cast
return func(*self.__args, **self.__kw)
File "/home/nicola/django18/lib/python2.7/site-
packages/Django-1.8.1-py2.7.egg/django/utils/translation/__init__.py",
line 84, in ugettext
return _trans.ugettext(message)
File "/home/nicola/django18/lib/python2.7/site-
packages/Django-1.8.1-py2.7.egg/django/utils/translation/trans_real.py",
line 327, in ugettext
return do_translate(message, 'ugettext')
File "/home/nicola/django18/lib/python2.7/site-
packages/Django-1.8.1-py2.7.egg/django/utils/translation/trans_real.py",
line 307, in do_translate
result = getattr(translation_object,
translation_function)(eol_message)
File "/usr/lib64/python2.7/gettext.py", line 220, in ugettext
return unicode(message)
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc2 in position 3:
ordinal not in range(128)
}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24741>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

Django

unread,
May 4, 2015, 8:22:30 AM5/4/15
to django-...@googlegroups.com
#24741: migration error
----------------------------+--------------------------------------
Reporter: drakkan | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.8
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed
Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by timgraham):

* status: new => closed
* needs_better_patch: => 0
* resolution: => needsinfo
* needs_tests: => 0
* needs_docs: => 0


Comment:

It's unclear if this is a bug in your project or in Django. Could you
please a sample project that reproduces the error and reopen the ticket?
Thanks.

--
Ticket URL: <https://code.djangoproject.com/ticket/24741#comment:1>

Django

unread,
May 4, 2015, 8:23:16 AM5/4/15
to django-...@googlegroups.com
#24741: UnicodeDecodeError in gettext via migrations autodetector
----------------------------+--------------------------------------
Reporter: drakkan | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.8
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------

--
Ticket URL: <https://code.djangoproject.com/ticket/24741#comment:2>

Django

unread,
May 4, 2015, 3:08:03 PM5/4/15
to django-...@googlegroups.com
#24741: UnicodeDecodeError in gettext via migrations autodetector
----------------------------+--------------------------------------
Reporter: drakkan | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.8
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------

Comment (by drakkan):

I think you can reproduce with a models like this


{{{
# -*- coding: utf-8 -*-
from django.db import models
#from django.utils.translation import ugettext_lazy as _
from django.utils.translation import ugettext as _

IMAGE_ROTATION = (
(0,_("None")),
(90,_("90 °")),
(180,_("180 °")),
(270,_("270 °")),
)

class TestModel(models.Model):
rotations =
models.SmallIntegerField(choices=IMAGE_ROTATION,default=0)
}}}

makemigration fails, in my project migrations was done with 1.7 version

--
Ticket URL: <https://code.djangoproject.com/ticket/24741#comment:3>

Django

unread,
May 4, 2015, 3:22:02 PM5/4/15
to django-...@googlegroups.com
#24741: UnicodeDecodeError in gettext via migrations autodetector
----------------------------+--------------------------------------
Reporter: drakkan | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.8
Severity: Normal | Resolution: needsinfo
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------

Comment (by drakkan):

and is solved using something like this:


{{{


IMAGE_ROTATION = (
(0,_("None")),

(90,_(u"90 °")),
(180,_(u"180 °")),
(270,_(u"270 °")),
)

}}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24741#comment:4>

Django

unread,
May 4, 2015, 3:47:45 PM5/4/15
to django-...@googlegroups.com
#24741: UnicodeDecodeError in gettext via migrations autodetector
----------------------------+--------------------------------------
Reporter: drakkan | Owner: nobody
Type: Bug | Status: closed
Component: Migrations | Version: 1.8
Severity: Normal | Resolution: invalid
Keywords: | Triage Stage: Unreviewed

Has patch: 0 | Needs documentation: 0
Needs tests: 0 | Patch needs improvement: 0

Easy pickings: 0 | UI/UX: 0
----------------------------+--------------------------------------
Changes (by charettes):

* resolution: needsinfo => invalid


Comment:

Hi drakkan,

As the name of the `ugettext` and `ugettext_lazy` method indicate they
expect a `unicode` parameter to be provided.

When you call `ugettext()` with a `utf-8` encoded byte string the method
crash as expected and works correctly when you pass unicode strings (`u`
prefixed strings).

I would suggest you make sure to define your translation strings as
`unicode` by either prefixing them with the `u` prefix or using `from
__future__ import unicode_literals`. If you must retrieve a translated
string from a byte strings use the `gettext` and `gettext_lazy` method
instead. Just keep in mind that Django expects `unicode` to be provided
internally when dealing with localization.

--
Ticket URL: <https://code.djangoproject.com/ticket/24741#comment:5>

Reply all
Reply to author
Forward
0 new messages