From 5e167bf8988dbd4b3c82379f72eb8a4e69645661 Mon Sep 17 00:00:00 2001 From: JasonHomeWorkstationUbuntu Date: Wed, 11 Nov 2020 14:41:27 +1100 Subject: [PATCH] 7.9.1 A Foreign Key Relationship --- src/lists/migrations/0001_initial.py | 23 ++++++++++++++++ .../migrations/0002_auto_20201111_0340.py | 27 +++++++++++++++++++ src/lists/models.py | 6 ++++- 3 files changed, 55 insertions(+), 1 deletion(-) create mode 100644 src/lists/migrations/0001_initial.py create mode 100644 src/lists/migrations/0002_auto_20201111_0340.py diff --git a/src/lists/migrations/0001_initial.py b/src/lists/migrations/0001_initial.py new file mode 100644 index 0000000..36f5055 --- /dev/null +++ b/src/lists/migrations/0001_initial.py @@ -0,0 +1,23 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.29 on 2020-11-10 12:36 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + initial = True + + dependencies = [ + ] + + operations = [ + migrations.CreateModel( + name='Item', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ('text', models.TextField(default='')), + ], + ), + ] diff --git a/src/lists/migrations/0002_auto_20201111_0340.py b/src/lists/migrations/0002_auto_20201111_0340.py new file mode 100644 index 0000000..c08fdb8 --- /dev/null +++ b/src/lists/migrations/0002_auto_20201111_0340.py @@ -0,0 +1,27 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.29 on 2020-11-11 03:40 +from __future__ import unicode_literals + +from django.db import migrations, models +import django.db.models.deletion + + +class Migration(migrations.Migration): + + dependencies = [ + ('lists', '0001_initial'), + ] + + operations = [ + migrations.CreateModel( + name='List', + fields=[ + ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), + ], + ), + migrations.AddField( + model_name='item', + name='list', + field=models.ForeignKey(default=None, on_delete=django.db.models.deletion.CASCADE, to='lists.List'), + ), + ] diff --git a/src/lists/models.py b/src/lists/models.py index 7ba0fdd..f95484c 100644 --- a/src/lists/models.py +++ b/src/lists/models.py @@ -1,4 +1,8 @@ from django.db import models +class List(models.Model): + pass + class Item(models.Model): - text = models.TextField(default='') \ No newline at end of file + text = models.TextField(default='') + list = models.ForeignKey(List, default=None) \ No newline at end of file