N
N
nik90192020-07-26 21:58:57
Django
nik9019, 2020-07-26 21:58:57

What is the correct way to make changes to a django model?

I am new to python, django and programming in general. Essence of the question.

There is a model on the basis of which the database is made (i.e. migration, if I understand correctly how everything works).

The model looks like this:

class Order(models.Model):
    data = models.DateField()
    time = models.TimeField(null=True)
    order_type = models.CharField(max_length=20)
    name = models.CharField(max_length=60, null=True)
    count = models.IntegerField(null=True)
    comment = models.CharField(max_length=60, null=True)


How to correctly make changes to the model if I want to add something to the database (for example, I need a field\value true\false)? How to make a migration?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
M
Maxim, 2020-07-27
@nik9019

1. Make any necessary changes to the model
2. Run python manage.py makemigrations
in the console 3. Locally or on a remote server (after migrating) run python manage.py migrate in the console

D
Dr. Bacon, 2020-07-27
@bacon

https://docs.djangoproject.com/en/3.0/topics/migra...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question