Add models Location and Event

parent efd8c198
# Generated by Django 4.1.7 on 2023-03-05 14:22
from django.db import migrations, models
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='IndexCard',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('name', models.CharField(max_length=100)),
('section', models.CharField(max_length=5)),
('age', models.IntegerField()),
],
),
]
# Generated by Django 4.1.7 on 2023-03-05 16:24
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
dependencies = [
('widget_Calendar', '0001_initial'),
]
operations = [
migrations.CreateModel(
name='Event',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('target_datetime', models.CharField(max_length=20)),
('activity', models.CharField(max_length=100)),
('estimated_hours', models.FloatField()),
('course', models.CharField(max_length=20)),
],
),
migrations.CreateModel(
name='Location',
fields=[
('id', models.BigAutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('mode', models.CharField(choices=[('onsite', 'Onsite'), ('online', 'Online'), ('hybrid', 'Hybrid')], max_length=6)),
('venue', models.CharField(max_length=100)),
],
),
migrations.DeleteModel(
name='IndexCard',
),
migrations.AddField(
model_name='event',
name='location',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='widget_Calendar.location'),
),
]
from django.db import models from django.db import models
# Create your models here.
class Location(models.Model):
MODE_TYPES = (
('onsite', 'Onsite'),
('online', 'Online'),
('hybrid', 'Hybrid'),
)
mode = models.CharField(max_length=6, choices=MODE_TYPES)
venue = models.CharField(max_length=100)
def __str__(self):
return 'Mode: {} || Venue: {}'.format(self.mode, self.venue)
class Event(models.Model):
target_datetime = models.CharField(max_length=20)
activity = models.CharField(max_length=100)
estimated_hours = models.FloatField()
location = models.ForeignKey(
Location,
on_delete=models.CASCADE
)
course = models.CharField(max_length=20)
def __str__(self):
return '{} on {}'.format(self.activity, self.target_datetime)
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment