Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use timezone.now for model defaults #149

Merged
merged 1 commit into from May 24, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
31 changes: 31 additions & 0 deletions normandy/recipes/migrations/0028_auto_20160524_1756.py
@@ -0,0 +1,31 @@
# -*- coding: utf-8 -*-
# Generated by Django 1.9 on 2016-05-24 17:56
from __future__ import unicode_literals

from django.db import migrations, models
import django.utils.timezone


class Migration(migrations.Migration):

dependencies = [
('recipes', '0027_auto_20160509_2225'),
]

operations = [
migrations.AlterField(
model_name='approval',
name='created',
field=models.DateTimeField(default=django.utils.timezone.now),
),
migrations.AlterField(
model_name='approvalrequest',
name='created',
field=models.DateTimeField(default=django.utils.timezone.now),
),
migrations.AlterField(
model_name='approvalrequestcomment',
name='created',
field=models.DateTimeField(default=django.utils.timezone.now),
),
]
9 changes: 4 additions & 5 deletions normandy/recipes/models.py
Expand Up @@ -2,10 +2,9 @@
import json
import logging

from datetime import datetime

from django.contrib.auth.models import User
from django.db import models, transaction
from django.utils import timezone
from django.utils.functional import cached_property

from dirtyfields import DirtyFieldsMixin
Expand Down Expand Up @@ -60,7 +59,7 @@ def __str__(self):


class Approval(models.Model):
created = models.DateTimeField(default=datetime.now)
created = models.DateTimeField(default=timezone.now)
creator = models.ForeignKey(User)


Expand Down Expand Up @@ -204,7 +203,7 @@ def request_time(self):

class ApprovalRequest(models.Model):
recipe = models.ForeignKey(Recipe, related_name='approval_requests')
created = models.DateTimeField(default=datetime.now)
created = models.DateTimeField(default=timezone.now)
creator = models.ForeignKey(User)
active = models.BooleanField(default=True)
approval = models.OneToOneField(Approval, null=True, related_name='approval_request')
Expand Down Expand Up @@ -259,6 +258,6 @@ def save(self, *args, **kwargs):

class ApprovalRequestComment(models.Model):
approval_request = models.ForeignKey(ApprovalRequest, related_name='comments')
created = models.DateTimeField(default=datetime.now)
created = models.DateTimeField(default=timezone.now)
creator = models.ForeignKey(User)
text = models.TextField()