From bd7bf3a1e4d46f344865283f20f7ab23d20300de Mon Sep 17 00:00:00 2001 From: tamirmatok Date: Wed, 27 Apr 2022 18:32:09 +0300 Subject: [PATCH] Add area choices to day-care model. Adding area choices for make the data model compatible, which will improve search for day care by area results. Signed-off-by: tamirmatok --- daycare/migrations/0006_alter_daycare_area.py | 20 +++++++++++++++++++ daycare/models.py | 8 +++++++- 2 files changed, 27 insertions(+), 1 deletion(-) create mode 100644 daycare/migrations/0006_alter_daycare_area.py diff --git a/daycare/migrations/0006_alter_daycare_area.py b/daycare/migrations/0006_alter_daycare_area.py new file mode 100644 index 0000000..73bd90d --- /dev/null +++ b/daycare/migrations/0006_alter_daycare_area.py @@ -0,0 +1,20 @@ +# Generated by Django 4.0.3 on 2022-04-27 13:37 + +import django.core.validators +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('daycare', '0005_image_data_migration'), + ] + + operations = [ + migrations.AlterField( + model_name='daycare', + name='area', + field=models.CharField(blank=True, choices=[('N', 'NORTH'), ('S', 'SOUTH'), ('C', 'CENTER')], + max_length=20, validators=[django.core.validators.MaxLengthValidator]), + ), + ] diff --git a/daycare/models.py b/daycare/models.py index 54aa6ea..6911299 100644 --- a/daycare/models.py +++ b/daycare/models.py @@ -10,13 +10,19 @@ from django.core.exceptions import ObjectDoesNotExist +class Area(models.TextChoices): + North = 'N', 'NORTH' + South = 'S', 'SOUTH' + Center = 'C', 'CENTER' + + class DayCare(models.Model): user = models.OneToOneField(User, on_delete=models.CASCADE, default=None, blank=True, null=False, editable=True) name = models.CharField(max_length=20, blank=True, unique=True, validators=[MaxLengthValidator]) description = models.TextField(blank=True, null=True) price_per_day = models.IntegerField(blank=False, null=False, default=0) capacity = models.IntegerField(null=False, blank=True) - area = models.CharField(max_length=20, blank=True, validators=[MaxLengthValidator]) + area = models.CharField(max_length=20, blank=True, validators=[MaxLengthValidator], choices=Area.choices) city = models.CharField(max_length=20, blank=True, validators=[MaxLengthValidator]) address = models.CharField(max_length=50, blank=True, validators=[MaxLengthValidator])