From 81c5f883cbcc17561f540f3db9da1bc29c04e808 Mon Sep 17 00:00:00 2001 From: Simeon J Morgan Date: Thu, 8 Sep 2022 15:04:29 +1000 Subject: [PATCH] Shorten email field; add colour --- .../migrations/0002_person_email_address.py | 18 ------------- ...n_email_address_person_favourite_colour.py | 25 +++++++++++++++++++ src/community_db/models.py | 7 +++++- 3 files changed, 31 insertions(+), 19 deletions(-) delete mode 100644 src/community_db/migrations/0002_person_email_address.py create mode 100644 src/community_db/migrations/0002_person_email_address_person_favourite_colour.py diff --git a/src/community_db/migrations/0002_person_email_address.py b/src/community_db/migrations/0002_person_email_address.py deleted file mode 100644 index b156c5a..0000000 --- a/src/community_db/migrations/0002_person_email_address.py +++ /dev/null @@ -1,18 +0,0 @@ -# Generated by Django 4.1 on 2022-09-08 04:59 - -from django.db import migrations, models - - -class Migration(migrations.Migration): - - dependencies = [ - ("community_db", "0001_initial"), - ] - - operations = [ - migrations.AddField( - model_name="person", - name="email_address", - field=models.EmailField(blank=True, max_length=900), - ), - ] diff --git a/src/community_db/migrations/0002_person_email_address_person_favourite_colour.py b/src/community_db/migrations/0002_person_email_address_person_favourite_colour.py new file mode 100644 index 0000000..1d97978 --- /dev/null +++ b/src/community_db/migrations/0002_person_email_address_person_favourite_colour.py @@ -0,0 +1,25 @@ +# Generated by Django 4.1 on 2022-09-08 05:03 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ("community_db", "0001_initial"), + ] + + operations = [ + migrations.AddField( + model_name="person", + name="email_address", + field=models.EmailField(blank=True, max_length=800), + ), + migrations.AddField( + model_name="person", + name="favourite_colour", + field=models.CharField( + choices=[("red", "red"), ("blue", "blue")], default="red", max_length=50 + ), + ), + ] diff --git a/src/community_db/models.py b/src/community_db/models.py index d7f1f46..c50a4d5 100644 --- a/src/community_db/models.py +++ b/src/community_db/models.py @@ -2,8 +2,13 @@ class Person(models.Model): + class Colours(models.TextChoices): + RED = ('red', 'red') + BLUE = ('blue', 'blue') + first_name = models.CharField(max_length=100) last_name = models.CharField(max_length=100, blank=True) country = models.CharField(max_length=100, blank=True) mobile_number = models.CharField(max_length=20, blank=True) - email_address = models.EmailField(max_length=900, blank=True) \ No newline at end of file + email_address = models.EmailField(max_length=800, blank=True) + favourite_colour = models.CharField(max_length=50, choices=Colours.choices, default=Colours.RED.value) \ No newline at end of file