diff --git a/pracman/practice/migrations/0001_initial.py b/pracman/practice/migrations/0001_initial.py index ced83ce..11dde15 100644 --- a/pracman/practice/migrations/0001_initial.py +++ b/pracman/practice/migrations/0001_initial.py @@ -1,6 +1,4 @@ -# -*- coding: utf-8 -*- -# Generated by Django 1.11.5 on 2017-09-22 00:02 -from __future__ import unicode_literals +# Generated by Django 2.1.7 on 2019-03-05 12:39 from django.conf import settings import django.contrib.auth.models @@ -15,7 +13,7 @@ class Migration(migrations.Migration): initial = True dependencies = [ - ('auth', '0008_alter_user_username_max_length'), + ('auth', '0009_alter_user_last_name_max_length'), ] operations = [ @@ -28,7 +26,7 @@ class Migration(migrations.Migration): ('is_superuser', models.BooleanField(default=False, help_text='Designates that this user has all permissions without explicitly assigning them.', verbose_name='superuser status')), ('username', models.CharField(error_messages={'unique': 'A user with that username already exists.'}, help_text='Required. 150 characters or fewer. Letters, digits and @/./+/-/_ only.', max_length=150, unique=True, validators=[django.contrib.auth.validators.UnicodeUsernameValidator()], verbose_name='username')), ('first_name', models.CharField(blank=True, max_length=30, verbose_name='first name')), - ('last_name', models.CharField(blank=True, max_length=30, verbose_name='last name')), + ('last_name', models.CharField(blank=True, max_length=150, verbose_name='last name')), ('email', models.EmailField(blank=True, max_length=254, verbose_name='email address')), ('is_staff', models.BooleanField(default=False, help_text='Designates whether the user can log into this admin site.', verbose_name='staff status')), ('is_active', models.BooleanField(default=True, help_text='Designates whether this user should be treated as active. Unselect this instead of deleting accounts.', verbose_name='active')), @@ -48,7 +46,7 @@ class Migration(migrations.Migration): ('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')), ('at', models.DateTimeField()), ('created_at', models.DateTimeField(auto_now_add=True)), - ('doctor', models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to=settings.AUTH_USER_MODEL)), + ('doctor', models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to=settings.AUTH_USER_MODEL)), ], options={ 'ordering': ('-at',), @@ -74,17 +72,17 @@ class Migration(migrations.Migration): migrations.AddField( model_name='patient', name='practice', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='practice.Practice'), + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='practice.Practice'), ), migrations.AddField( model_name='appointment', name='patient', - field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='practice.Patient'), + field=models.ForeignKey(on_delete=django.db.models.deletion.PROTECT, to='practice.Patient'), ), migrations.AddField( model_name='doctor', name='practice', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, related_name='doctors', to='practice.Practice'), + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.PROTECT, related_name='doctors', to='practice.Practice'), ), migrations.AddField( model_name='doctor', @@ -93,6 +91,6 @@ class Migration(migrations.Migration): ), migrations.AlterUniqueTogether( name='appointment', - unique_together=set([('doctor', 'at')]), + unique_together={('doctor', 'at')}, ), ] diff --git a/pracman/practice/models.py b/pracman/practice/models.py index 9b8b628..bf1a5f1 100644 --- a/pracman/practice/models.py +++ b/pracman/practice/models.py @@ -15,7 +15,7 @@ def __str__(self): class Doctor(AbstractUser): - practice = models.ForeignKey('practice.Practice', null=True, blank=True, related_name='doctors') + practice = models.ForeignKey('practice.Practice', null=True, blank=True, related_name='doctors', on_delete=models.PROTECT) class Meta: verbose_name_plural = 'Doctors' @@ -24,7 +24,7 @@ class Meta: class Patient(models.Model): name = models.CharField(max_length=128) - practice = models.ForeignKey('practice.Practice') + practice = models.ForeignKey('practice.Practice', on_delete=models.PROTECT) create_at = models.DateTimeField(auto_now_add=True) objects = querysets.PatientQuerySet.as_manager() @@ -35,8 +35,8 @@ def __str__(self): class Appointment(models.Model): - doctor = models.ForeignKey('practice.Doctor') - patient = models.ForeignKey('practice.Patient') + doctor = models.ForeignKey('practice.Doctor', on_delete=models.PROTECT) + patient = models.ForeignKey('practice.Patient', on_delete=models.PROTECT) at = models.DateTimeField() created_at = models.DateTimeField(auto_now_add=True) diff --git a/requirements.txt b/requirements.txt index 3e0a788..2f19d37 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,2 +1,2 @@ -Django==1.11.5 -djangorestframework==3.6.4 +Django==2.1.7 +djangorestframework==3.9.1