From 7478068a14c6a15d16c48f7086d6391e52137b0c Mon Sep 17 00:00:00 2001 From: Johnathan Graydon Date: Sun, 13 Jan 2019 16:30:45 +0000 Subject: [PATCH] Fix defaults, will close #3 Moved to template now model as it both fixed the bug and consolidated edit points --- models.py | 4 ++-- templates/asset_update.html | 10 ++++++++-- 2 files changed, 10 insertions(+), 4 deletions(-) diff --git a/models.py b/models.py index a820baf7..3276d941 100644 --- a/models.py +++ b/models.py @@ -42,10 +42,10 @@ class BaseAsset(models.Model): asset_id = models.CharField(max_length=10) description = models.CharField(max_length=120) category = models.ForeignKey(to=AssetCategory, on_delete=models.CASCADE) - status = models.ForeignKey(to=AssetStatus, on_delete=models.CASCADE, default='Active') + status = models.ForeignKey(to=AssetStatus, on_delete=models.CASCADE) serial_number = models.CharField(max_length=150, blank=True) purchased_from = models.ForeignKey(to=Supplier, on_delete=models.CASCADE, blank=True, null=True) - date_acquired = models.DateField(default=datetime.date.today().strftime('%d %b %Y')) + date_acquired = models.DateField() date_sold = models.DateField(blank=True, null=True) purchase_price = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=10) salvage_value = models.DecimalField(blank=True, null=True, decimal_places=2, max_digits=10) diff --git a/templates/asset_update.html b/templates/asset_update.html index fd0d6bf8..1b302d49 100644 --- a/templates/asset_update.html +++ b/templates/asset_update.html @@ -73,7 +73,8 @@
@@ -143,7 +144,12 @@
- {% render_field form.date_acquired|add_class:'datepicker' value=object.date_acquired|date %} + {% if object.date_acquired %} + {% render_field form.date_acquired|add_class:'datepicker' value=object.date_acquired|date %} + {% else %} + + {% endif %}