Skip to content

armgit / wger

Public Imported from GitHub
0

Self hosted FLOSS fitness/workout, nutrition and weight tracker

Change measurement entry default to be timezone-aware

Roland Geiderbd0bcd913455
diff --git a/wger/measurements/migrations/0007_alter_measurement_date.py b/wger/measurements/migrations/0007_alter_measurement_date.py
new file mode 100644
index 000000000..81e335caa
--- /dev/null
+++ b/wger/measurements/migrations/0007_alter_measurement_date.py
@@ -0,0 +1,18 @@
+import django.utils.timezone
+from django.db import migrations, models
+
+
+class Migration(migrations.Migration):
+ """This only changes de default"""
+
+ dependencies = [
+ ('measurements', '0006_change_measurement_pk_to_uuid'),
+ ]
+
+ operations = [
+ migrations.AlterField(
+ model_name='measurement',
+ name='date',
+ field=models.DateTimeField(default=django.utils.timezone.now, verbose_name='Date'),
+ ),
+ ]
diff --git a/wger/measurements/models/measurement.py b/wger/measurements/models/measurement.py
index c945a7244..43d14c01c 100644
--- a/wger/measurements/models/measurement.py
+++ b/wger/measurements/models/measurement.py
@@ -12,11 +12,6 @@
#
# You should have received a copy of the GNU Affero General Public License
# along with Workout Manager. If not, see <http://www.gnu.org/licenses/>.
-# Standard Library
-
-# Standard Library
-import datetime
-import uuid
# Django
from django.core.validators import (
@@ -24,6 +19,7 @@ from django.core.validators import (
MinValueValidator,
)
from django.db import models
+from django.utils import timezone
# wger
from wger.measurements.models import Category
@@ -52,7 +48,7 @@ class Measurement(models.Model):
date = models.DateTimeField(
verbose_name='Date',
- default=datetime.datetime.now,
+ default=timezone.now,
)
value = models.DecimalField(