Skip to content

Commit

Permalink
Add area choices to day-care model.
Browse files Browse the repository at this point in the history
Adding area choices for make the data model compatible,
which will improve search for day care by area results.

Signed-off-by: tamirmatok <[email protected]>
  • Loading branch information
tamirmatok authored and ErezCohenn committed May 12, 2022
1 parent 85cdd48 commit e815468
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 1 deletion.
20 changes: 20 additions & 0 deletions daycare/migrations/0006_alter_daycare_area.py
Original file line number Diff line number Diff line change
@@ -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]),
),
]
8 changes: 7 additions & 1 deletion daycare/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -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])

Expand Down

0 comments on commit e815468

Please sign in to comment.