小编min*_*ing的帖子

在向模型添加字段后,"没有这样的列"

环境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)

python django

10
推荐指数
3
解决办法
2万
查看次数

我安装了python 2.7和3.5,但python 3.5不能正常工作

在终端,我可以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)

python python-2.7 python-3.x

6
推荐指数
1
解决办法
1227
查看次数

标签 统计

python ×2

django ×1

python-2.7 ×1

python-3.x ×1