Notice: This page requires JavaScript to function properly.
Please enable JavaScript in your browser settings or update your browser.
Migrations | Models
Django: First Dive
course content

Зміст курсу

Django: First Dive

Django: First Dive

1. Get Started
2. Write the First Page
3. Models
4. Working with Database
5. Templates
6. Request Handling

bookMigrations

The Python code is independent of the database.

To apply changes in our database, we need to create migrations.

Migration is the automated way of making changes to your database structure, ensuring that your database stays up to changes you make to your code.

When you create the Model class, you need to run the following commands in the Terminal:

makemigrations

The python manage.py makemigrations command records the changes in the database and creates migrations.

Migrations are represented as Python files (.py format).

These files contain scripts and data for migration and database structure changes.

Note

This is the process of the framework. Migrations work automatically. You do not need to touch these files. Only sometimes, there are moments when it is desirable to delete the migration and create a new one, but this is only a last resort.

migrate

To apply created migrations, you need to run another command in the Terminal.
The command python manage.py migrate executes migrations scripts (.py files) and sends queries to the database.

Note

When you move the Django to another device, you can run the migrate command only because the migrations are already saved in files.

1. How to create migration files?
2. How to apply migrations?
question-icon

How to create migration files?

Натисніть або перетягніть елементи та заповніть пропуски

question-icon

How to apply migrations?

Натисніть або перетягніть елементи та заповніть пропуски

Все було зрозуміло?

Як ми можемо покращити це?

Дякуємо за ваш відгук!

Секція 3. Розділ 4
some-alt