feat: add Exercise model and CRUD API for tutorial exercises
Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
29
tutorial/migrations/0004_exercise.py
Normal file
29
tutorial/migrations/0004_exercise.py
Normal file
@@ -0,0 +1,29 @@
|
||||
# Generated by Django 6.0 on 2026-04-23 07:31
|
||||
|
||||
import django.db.models.deletion
|
||||
from django.db import migrations, models
|
||||
|
||||
|
||||
class Migration(migrations.Migration):
|
||||
|
||||
dependencies = [
|
||||
('tutorial', '0003_alter_tutorial_code'),
|
||||
]
|
||||
|
||||
operations = [
|
||||
migrations.CreateModel(
|
||||
name='Exercise',
|
||||
fields=[
|
||||
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
|
||||
('type', models.CharField(choices=[('mcq', '选择题'), ('sort', '代码排序')], max_length=16)),
|
||||
('data', models.JSONField()),
|
||||
('order', models.IntegerField(default=0)),
|
||||
('created_at', models.DateTimeField(auto_now_add=True)),
|
||||
('tutorial', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, related_name='exercises', to='tutorial.tutorial')),
|
||||
],
|
||||
options={
|
||||
'db_table': 'exercise',
|
||||
'ordering': ['order', 'created_at'],
|
||||
},
|
||||
),
|
||||
]
|
||||
Reference in New Issue
Block a user