# stay Model in
class Meta:
db_table = "new_tablename" # Change table name
1. Directly in models.py add
class User(models.Model):
username=models.CharField(max_length=50)
password=models.CharField(max_length=50)
zhname = models.CharField(max_length=50)
I added the zhname = models.CharField(max_length=50)
And then in turn
1.python manage.py makemigrations
2.python manage.py migrate
Error when executing the first sentence
You are trying to add a non-nullable field 'name' to contact without a default; we can't do that (the database needs something to populate existing rows).
Please select a fix:
1) Provide a one-off default now (will be set on all existing rows with a null value for this column)
2) Quit, and let me add a default in models.py
Select an option:
resolvent : to zhname Give initial value ’abc’
zhname = models.CharField(max_length=50,default='abc')
And then execute one after the other
python manage.py makemigrations
python manage.py migrate
Delete default Default initial value default=‘abc’
Re execution
python manage.py makemigrations
python manage.py migrate