2017-08-09 4 views
0

Ich poste meine Modelle unten, aber bitte beachten Sie, dass ich das Präfix "u" überall verwende und die magische Kodierungslinie als zweite Zeile meiner Datei hinzugefügt habe. Ich bin mit django 1.9 und Python 2.7DjangoUnicodeDecodeError beim Ausführen von Makemigrationen

MODEL

#!/usr/bin/env python 
# -*- coding: utf-8 -*- 

from django.db import models 
from django.utils.translation import ugettext_lazy as _ 

class Organisaatio(models.Model): 
    organisaation_nimi = models.CharField(
     verbose_name=_(u"Organisaation nimi"), 
     max_length=128, 
     null=True, 
     blank=True, 
     help_text=_(u"Organisaatiosi nimi"), 
     ) 

    organisaation_koko = models.IntegerField(
     verbose_name=_(u"Organisaation Koko"), 
     null=True, 
     blank=True, 
     help_text=_(u"Arvio organisaatiosi jäsenmaräästä"), 
     ) 

    kuvaus = models.TextField(
     verbose_name=_(u"Tehtävän kuvaus"), 
     blank=True, 
     default="", 
     help_text=_(u"Kuvaile tehtävää"), 
     ) 

    kesto = models.DecimalField(
     verbose_name=_(u"Tehtävään käytetty aika"), 
     max_digits = 3, 
     decimal_places=2, 
     null=True, 
     help_text=_(u"Arvioi tunneissa, kuinka kauan tehtävään käytetään keskimäärin aikaa"), 
     ) 

    kertaa = models.IntegerField(
     verbose_name=_(u"Kertaa per kuukausi"), 
     null=True, 
     blank=True, 
     help_text=_(u"Arvioi kuinka monta kertaa kuukauden aikana tehtävä tehdään") 
     ) 


    def __unicode__(self): 
     return self.organisaation_nimi 

Nach dem makemigrations Befehl ausgeführt wird, startet sie die Make-Datei zu erstellen:

Migrations for 'app': 
    0002_auto_20170809_1628.py: 
    - Create model Kysymys 
    - Add field kertaa to organisaatio 
    - Add field kesto to organisaatio 
    - Add field kuvaus to organisaatio 
    - Alter field organisaation_koko on organisaatio 
    - Alter field organisaation_nimi on organisaatio 

und dann spuckt ein Unicode-Fehler:

django.utils.encoding.DjangoUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 21: ordinal not in range(128). You passed in 
<django.utils.functional.__proxy__ object at 0x109ba0ad0> (<class 
'django.utils.functional.__proxy__'>) 

Ich bin perplex, wie ich festgestellt habe Ich habe die Codierung am Anfang der Datei geändert und verwende überall das Präfix u.

Danke für Ihre Zeit!

EDIT

Hier ist die Zurückverfolgungs:

Traceback (most recent call last): 
    File "manage.py", line 17, in <module> 
    execute_from_command_line(sys.argv) 
    File "/Users/user/anaconda/envs/my_project/lib/python2.7/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line 
    utility.execute() 
    File "/Users/user/anaconda/envs/my_project/lib/python2.7/site-packages/django/core/management/__init__.py", line 345, in execute 
    self.fetch_command(subcommand).run_from_argv(self.argv) 
    File "/Users/user/anaconda/envs/my_project/lib/python2.7/site-packages/django/core/management/base.py", line 348, in run_from_argv 
    self.execute(*args, **cmd_options) 
    File "/Users/user/anaconda/envs/my_project/lib/python2.7/site-packages/django/core/management/base.py", line 399, in execute 
    output = self.handle(*args, **options) 
    File "/Users/user/anaconda/envs/my_project/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 150, in handle 
    self.write_migration_files(changes) 
    File "/Users/user/anaconda/envs/my_project/lib/python2.7/site-packages/django/core/management/commands/makemigrations.py", line 178, in write_migration_files 
    migration_string = writer.as_string() 
    File "/Users/user/anaconda/envs/my_project/lib/python2.7/site-packages/django/db/migrations/writer.py", line 167, in as_string 
    operation_string, operation_imports = OperationWriter(operation).serialize() 
    File "/Users/user/anaconda/envs/my_project/lib/python2.7/site-packages/django/db/migrations/writer.py", line 124, in serialize 
    _write(arg_name, arg_value) 
    File "/Users/user/anaconda/envs/my_project/lib/python2.7/site-packages/django/db/migrations/writer.py", line 76, in _write 
    arg_string, arg_imports = MigrationWriter.serialize(item) 
    File "/Users/user/anaconda/envs/my_project/lib/python2.7/site-packages/django/db/migrations/writer.py", line 357, in serialize 
    item_string, item_imports = cls.serialize(item) 
    File "/Users/user/anaconda/envs/my_project/lib/python2.7/site-packages/django/db/migrations/writer.py", line 433, in serialize 
    return cls.serialize_deconstructed(path, args, kwargs) 
    File "/Users/user/anaconda/envs/my_project/lib/python2.7/site-packages/django/db/migrations/writer.py", line 318, in serialize_deconstructed 
    arg_string, arg_imports = cls.serialize(arg) 
    File "/Users/user/anaconda/envs/my_project/lib/python2.7/site-packages/django/db/migrations/writer.py", line 346, in serialize 
    value = force_text(value) 
    File "/Users/user/anaconda/envs/my_project/lib/python2.7/site-packages/django/utils/encoding.py", line 88, in force_text 
    raise DjangoUnicodeDecodeError(s, *e.args) 
django.utils.encoding.DjangoUnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 21: ordinal not in range(128). You passed in <django.utils.functional.__proxy__ object at 0x109898b10> (<class 'django.utils.functional.__proxy__'>) 
+0

Bitte, zeigen Sie vollständige Trace-Fehler –

+0

Ich habe die vollständige Spur jetzt hinzugefügt – P4nd4b0b3r1n0

Antwort

0

Versuchen Sie u ersetzen '...' mit b '...'

ich django zu auto-eröffne mein Migrationen (mit Makemigrationen) und tendiert dazu,

+0

Versucht es, aber es gibt immer noch den gleichen Fehler – P4nd4b0b3r1n0

0

Sie verwenden Django-Übersetzung, so dass Sie nicht Unicode innerhalb der verbose_name oder help_text verwenden müssen, ersetzen Sie diesen Text auf Englisch und versuchen Sie es.

Verwandte Themen