Codetail
Dashboard
Problems
Paths
Sessions
AC
Django Fundamentals
Run & Write Migrations
Easy
Write Code
Prev
3/10
Next
makemigrations / migrate
Description
After defining your `Post` model, create and apply the database migrations. Also write a custom data migration that creates a default admin user.
Requirements
01
Show the commands to create and apply migrations
02
Write a custom migration function using `RunPython`
03
The function should create a superuser with username 'admin'
Show 2 hints
Python 3
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
# Terminal commands: # 1. Create migrations: # 2. Apply migrations: # Custom data migration from django.db import migrations def create_superuser(apps, schema_editor): # Write your migration function here pass class Migration(migrations.Migration): dependencies = [ # Add dependency ] operations = [ # Add operation ]
Ln 18, Col 1
Submit for Review