From 7f57ace92d7f46bd0ae84029cbfcdade2726c784 Mon Sep 17 00:00:00 2001 From: PCoder Date: Sun, 1 Jul 2018 19:23:05 +0200 Subject: [PATCH] Set default and on_delete attributes --- ...uto_20180701_1631.py => 0045_auto_20180701_1718.py} | 6 +++--- hosting/models.py | 10 ++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) rename hosting/migrations/{0045_auto_20180701_1631.py => 0045_auto_20180701_1718.py} (73%) diff --git a/hosting/migrations/0045_auto_20180701_1631.py b/hosting/migrations/0045_auto_20180701_1718.py similarity index 73% rename from hosting/migrations/0045_auto_20180701_1631.py rename to hosting/migrations/0045_auto_20180701_1718.py index 8af4d821..d9705a24 100644 --- a/hosting/migrations/0045_auto_20180701_1631.py +++ b/hosting/migrations/0045_auto_20180701_1718.py @@ -1,5 +1,5 @@ # -*- coding: utf-8 -*- -# Generated by Django 1.9.4 on 2018-07-01 16:31 +# Generated by Django 1.9.4 on 2018-07-01 17:18 from __future__ import unicode_literals from django.db import migrations, models @@ -23,13 +23,13 @@ class Migration(migrations.Migration): ('memory', models.IntegerField(default=0)), ('hdd_size', models.IntegerField(default=0)), ('ssd_size', models.IntegerField(default=0)), - ('vm_template', models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='datacenterlight.VMTemplate')), + ('vm_template', models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to='datacenterlight.VMTemplate')), ], bases=(utils.mixins.AssignPermissionsMixin, models.Model), ), migrations.AddField( model_name='hostingorder', name='order_specs', - field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.CASCADE, to='hosting.OrderSpecifications'), + field=models.ForeignKey(blank=True, default=None, null=True, on_delete=django.db.models.deletion.SET_NULL, to='hosting.OrderSpecifications'), ), ] diff --git a/hosting/models.py b/hosting/models.py index c30a25a8..b182bfc5 100644 --- a/hosting/models.py +++ b/hosting/models.py @@ -42,7 +42,10 @@ class HostingPlan(models.Model): class OrderSpecifications(AssignPermissionsMixin, models.Model): - vm_template = models.ForeignKey(VMTemplate, blank=True, null=True) + vm_template = models.ForeignKey( + VMTemplate, blank=True, null=True, default=None, + on_delete=models.SET_NULL + ) cores = models.IntegerField(default=0) memory = models.IntegerField(default=0) hdd_size = models.IntegerField(default=0) @@ -69,7 +72,10 @@ class HostingOrder(AssignPermissionsMixin, models.Model): price = models.FloatField() subscription_id = models.CharField(max_length=100, null=True) vm_pricing = models.ForeignKey(VMPricing) - order_specs = models.ForeignKey(OrderSpecifications, null=True, blank=True) + order_specs = models.ForeignKey( + OrderSpecifications, null=True, blank=True, default=None, + on_delete=models.SET_NULL + ) permissions = ('view_hostingorder',)