diff --git a/authority/migrations/0001_initial.py b/authority/migrations/0001_initial.py index f17f6db..35c251d 100644 --- a/authority/migrations/0001_initial.py +++ b/authority/migrations/0001_initial.py @@ -24,10 +24,10 @@ class Migration(migrations.Migration): ('approved', models.BooleanField(default=False, help_text='Designates whether the permission has been approved and treated as active. Unselect this instead of deleting permissions.', verbose_name='approved')), ('date_requested', models.DateTimeField(default=datetime.datetime.now, verbose_name='date requested')), ('date_approved', models.DateTimeField(null=True, verbose_name='date approved', blank=True)), - ('content_type', models.ForeignKey(related_name='row_permissions', to='contenttypes.ContentType')), - ('creator', models.ForeignKey(related_name='created_permissions', blank=True, to=settings.AUTH_USER_MODEL, null=True)), - ('group', models.ForeignKey(blank=True, to='auth.Group', null=True)), - ('user', models.ForeignKey(related_name='granted_permissions', blank=True, to=settings.AUTH_USER_MODEL, null=True)), + ('content_type', models.ForeignKey(related_name='row_permissions', to='contenttypes.ContentType', on_delete=models.CASCADE)), + ('creator', models.ForeignKey(related_name='created_permissions', blank=True, to=settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE)), + ('group', models.ForeignKey(blank=True, to='auth.Group', null=True, on_delete=models.CASCADE)), + ('user', models.ForeignKey(related_name='granted_permissions', blank=True, to=settings.AUTH_USER_MODEL, null=True, on_delete=models.CASCADE)), ], options={ 'verbose_name': 'permission', diff --git a/authority/models.py b/authority/models.py index d6cca3b..174aed7 100644 --- a/authority/models.py +++ b/authority/models.py @@ -16,15 +16,15 @@ class Permission(models.Model): of any content type. """ codename = models.CharField(_('codename'), max_length=100) - content_type = models.ForeignKey(ContentType, related_name="row_permissions") + content_type = models.ForeignKey(ContentType, related_name="row_permissions", on_delete=models.CASCADE) object_id = models.PositiveIntegerField() content_object = GenericForeignKey('content_type', 'object_id') user = models.ForeignKey( - user_model_label, null=True, blank=True, related_name='granted_permissions') - group = models.ForeignKey(Group, null=True, blank=True) + user_model_label, null=True, blank=True, related_name='granted_permissions', on_delete=models.CASCADE) + group = models.ForeignKey(Group, null=True, blank=True, on_delete=models.CASCADE) creator = models.ForeignKey( - user_model_label, null=True, blank=True, related_name='created_permissions') + user_model_label, null=True, blank=True, related_name='created_permissions', on_delete=models.CASCADE) approved = models.BooleanField( _('approved'),