如何在已开发的 Django 用户 table 数据库中添加更多 table 字段

How can i add more table fields on already developed Django User table Database

我想在用户数据中添加更多字段table所以请解释正确的方法。

很简单,在你的User模型中models.py就简单了 添加另一个字段,

example:

class User(models.Model):
    name = models.CharField(max_length=100)
    phone = models.IntegerField()
    created_date = models.DateTimeField(default=timezone.now)
    modified_date = models.DateTimeField(default=timezone.now)

lets add the field email:

class User(models.Model):
    name = models.CharField(max_length=100)
    phone = models.IntegerField()
    email = models.CharField(max_length=100)
    created_date = models.DateTimeField(default=timezone.now)
    modified_date = models.DateTimeField(default=timezone.now)

then run this command in your terminal:

python manage.py makemigrations

and it will display the alter you are about to make and then run the command:

python manage.py migrate

新字段将是added.I希望这对你有帮助

干杯!