环境DJANGO VERSION 1.9 Python 2.7.6
我在models.py这样的模型类中添加了一个字段(分数)
from django.db import models
from django.contrib.auth.models import User
import urllib
import hashlib
class profile(models.Model):
user = models.OneToOneField(User)
nickname = models.CharField(max_length=12, blank=True, null=True)
use_gravatar = models.BooleanField(default=True)
location = models.CharField(max_length=20, blank=True, null=True)
avatar_url = models.URLField(blank=True, null=True)
website = models.URLField(blank=True, null=True)
**scores = models.IntegerField(default = 0)**
Run Code Online (Sandbox Code Playgroud)
我运行以下命令来同步数据库.
python manage.py makemigrations
python manage.py migrate
Run Code Online (Sandbox Code Playgroud)
但得到了这个
OperationalError at /
no such column: account_profile.scores
Request Method: GET
Request URL: http://127.0.0.1:8000/
Django Version: 1.8.4
Exception Type: OperationalError
Exception Value:
no such …Run Code Online (Sandbox Code Playgroud) 在终端,我可以py -2成功运行.尽管如此,
C:\Users\user>py -3
Fatal Python error: Py_Initialize: unable to load the file system codec
File "C:\Python27\lib\encodings\__init__.py", line 123
raise CodecRegistryError,\
^
SyntaxError: invalid syntax
Current thread 0x00004570 (most recent call first):
Run Code Online (Sandbox Code Playgroud)