Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Python 如何向django userprofile模型添加新列_Python_Django - Fatal编程技术网

Python 如何向django userprofile模型添加新列

Python 如何向django userprofile模型添加新列,python,django,Python,Django,我在Django用户身份验证中添加了一个额外的自定义字段phone。在那之前,它工作正常。后来,我又添加了一个名为permissions的自定义字段。之后,当我尝试访问管理页面时,我会遇到一条错误消息。这是我的model.pycode from django.contrib.auth.models import User from django.db import models class UserProfile(models.Model): # This line is require

我在Django用户身份验证中添加了一个额外的自定义字段
phone
。在那之前,它工作正常。后来,我又添加了一个名为
permissions
的自定义字段。之后,当我尝试访问管理页面时,我会遇到一条错误消息。这是我的
model.py
code

from django.contrib.auth.models import User
from django.db import models
class UserProfile(models.Model):
    # This line is required. Links UserProfile to a User model instance.
    user = models.OneToOneField(User)
    class Meta:
        permissions = (
                       ("ssc_1","can access ssc locked questions"),
                       )
    # The additional attributes we wish to include.
    phone = models.CharField(max_length =20)
    permission = models.IntegerField()   

    # Override the __unicode__() method to return out something meaningful!
    def __unicode__(self):
        return self.user.username
当我发出
python manage.py migrate
命令时,我收到了这个错误消息

return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: table "users_userprofile" already exists
注意:我的Django版本是1.6.6


谢谢

迁移只在django 1.7中引入。在此之前,它一直被用来处理迁移