How does Django take effect after changing the model of sqlite3

question

Modify the Image table to add the attribute auto_now = True to the time field:

class Image(models.Model):
    id = models.CharField(max_length=36, primary_key=True)
    path = models.CharField(max_length=100)
    status = models.IntegerField(default=2)
    operator = models.CharField(max_length=20)
    time = models.DateTimeField(auto_now = True)

How does it work?

solve

The same as the method when the model was first created, it is divided into two steps:

python manage.py makemigrations app_label

Create the latest version of the model, then

python manage.py migrate
Apply all migrations.



Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325969101&siteId=291194637