From 23ab6974fe566c567c39c9a4f60ecd31bccc46b5 Mon Sep 17 00:00:00 2001 From: Nathan Chapman Date: Sat, 30 Apr 2022 17:23:22 -0600 Subject: [PATCH 1/2] Remove required fields for order --- ...8_alter_order_coupon_alter_order_weight.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 src/core/migrations/0008_alter_order_coupon_alter_order_weight.py diff --git a/src/core/migrations/0008_alter_order_coupon_alter_order_weight.py b/src/core/migrations/0008_alter_order_coupon_alter_order_weight.py new file mode 100644 index 0000000..035f81e --- /dev/null +++ b/src/core/migrations/0008_alter_order_coupon_alter_order_weight.py @@ -0,0 +1,27 @@ +# Generated by Django 4.0.2 on 2022-04-30 23:11 + +import core.weight +from django.db import migrations, models +import django.db.models.deletion +import django_measurement.models +import measurement.measures.mass + + +class Migration(migrations.Migration): + + dependencies = [ + ('core', '0007_product_subtitle'), + ] + + operations = [ + migrations.AlterField( + model_name='order', + name='coupon', + field=models.ForeignKey(blank=True, null=True, on_delete=django.db.models.deletion.SET_NULL, related_name='orders', to='core.coupon'), + ), + migrations.AlterField( + model_name='order', + name='weight', + field=django_measurement.models.MeasurementField(blank=True, default=core.weight.zero_weight, measurement=measurement.measures.mass.Mass, null=True), + ), + ] From 47df760c5f4bdcd883af54ae48e74f9412dba544 Mon Sep 17 00:00:00 2001 From: Nathan Chapman Date: Sat, 30 Apr 2022 17:23:44 -0600 Subject: [PATCH 2/2] Remove required fields for order --- src/core/models.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/core/models.py b/src/core/models.py index 1141f51..fcbcf53 100644 --- a/src/core/models.py +++ b/src/core/models.py @@ -190,21 +190,21 @@ class Order(models.Model): related_name="+", editable=False, null=True, - on_delete=models.SET_NULL, + on_delete=models.SET_NULL ) shipping_address = models.ForeignKey( Address, related_name="+", editable=False, null=True, - on_delete=models.SET_NULL, + on_delete=models.SET_NULL ) shipping_method = models.ForeignKey( ShippingMethod, blank=True, null=True, related_name="orders", - on_delete=models.SET_NULL, + on_delete=models.SET_NULL ) @@ -212,6 +212,7 @@ class Order(models.Model): Coupon, related_name='orders', on_delete=models.SET_NULL, + blank=True, null=True ) @@ -224,7 +225,7 @@ class Order(models.Model): total_net_amount = models.DecimalField( max_digits=10, decimal_places=2, - default=0, + default=0 ) @@ -232,6 +233,8 @@ class Order(models.Model): measurement=Weight, unit_choices=WeightUnits.CHOICES, default=zero_weight, + blank=True, + null=True ) created_at = models.DateTimeField(auto_now_add=True, editable=False)