Django 1.7 python manage.py makemigrations民意调查
问题描述:
我学习Django教程,当我运行控制台命令时出现一些奇怪的错误。 0001_initial.py未在迁移文件夹中创建。Django 1.7 python manage.py makemigrations民意调查
python manage.py makemigrations polls
C:\Users\pc\Dropbox\ГуглДрайв\python\projects\pools\mysite> python manage.py makemigrations polls
Migrations for 'polls':
0001_initial.py:
- Create model Choice
- Create model Question
- Add field question to choice
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\management\__init__.py", lin
rom_command_line
utility.execute()
File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\management\__init__.py", lin
self.fetch_command(subcommand).run_from_argv(self.argv)
File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\management\base.py", line 28
self.execute(*args, **options.__dict__)
File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\management\base.py", line 33
output = self.handle(*args, **options)
File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\management\commands\makemigr
4, in handle
self.write_migration_files(changes)
File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\core\management\commands\makemigr
3, in write_migration_files
migrations_directory = os.path.dirname(writer.path)
File "C:\Python27\lib\site-packages\django-1.7.1-py2.7.egg\django\db\migrations\writer.py", line 21
return os.path.join(basedir, self.filename)
File "C:\Python27\lib\ntpath.py", line 84, in join
result_path = result_path + p_path
UnicodeDecodeError: 'ascii' codec can't decode byte 0xc3 in position 18: ordinal not in range(128)
Whatw wrong?
这是民意调查的文件夹
# -- coding: utf-8 -
from django.db import models
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
class Choice(models.Model):
question = models.ForeignKey(Question)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
答
我的models.py文件我怀疑问题在于 'ГуглДрайв'。尝试从路径中没有任何俄文名称的文件夹运行项目。如果你使用virtualenv,那么把它放在一个只有ASCII的路径中。请注意,virtualenv在移动时经常会中断;它需要被重新创建。
答
我同意Thijs van Dien的怀疑。你可能达不到这个问题:
https://github.com/pypa/virtualenv/issues/457
有一个固定在这里,你可以尝试,如果你不希望重命名ГуглДрайв:
https://github.com/atykhonov/virtualenv/commit/b3b51ccfd8a3863b028804df9ffc0ae832a60873
1)你创建一个默认的数据库ut8编码? 2)你是否在模型的顶部添加了# - * - coding:utf-8 - * - ? – 2014-12-07 10:01:09
嗨,迈克!我不知道 - 我使用默认的SQLlite基地 – imxoo 2014-12-07 10:09:10
你的python解释器的版本是什么? – iMom0 2014-12-07 10:17:45