From 23124dbe34576addc875e71bd603338d0dab32df Mon Sep 17 00:00:00 2001 From: Benjamin Dauvergne Date: Mon, 26 Mar 2018 15:25:54 +0200 Subject: [PATCH 1/2] oauth2: use auto_now_add for creation_date fields (#22682) --- fargo/oauth2/migrations/0004_auto_20180326_1330.py | 25 ++++++++++++++++++++++ fargo/oauth2/models.py | 4 ++-- 2 files changed, 27 insertions(+), 2 deletions(-) create mode 100644 fargo/oauth2/migrations/0004_auto_20180326_1330.py diff --git a/fargo/oauth2/migrations/0004_auto_20180326_1330.py b/fargo/oauth2/migrations/0004_auto_20180326_1330.py new file mode 100644 index 0000000..80c3f78 --- /dev/null +++ b/fargo/oauth2/migrations/0004_auto_20180326_1330.py @@ -0,0 +1,25 @@ +# -*- coding: utf-8 -*- +# Generated by Django 1.11.11 on 2018-03-26 13:30 +from __future__ import unicode_literals + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('oauth2', '0003_auto_20180322_1016'), + ] + + operations = [ + migrations.AlterField( + model_name='oauth2authorize', + name='creation_date', + field=models.DateTimeField(auto_now_add=True), + ), + migrations.AlterField( + model_name='oauth2tempfile', + name='creation_date', + field=models.DateTimeField(auto_now_add=True), + ), + ] diff --git a/fargo/oauth2/models.py b/fargo/oauth2/models.py index 2a00a49..d330643 100644 --- a/fargo/oauth2/models.py +++ b/fargo/oauth2/models.py @@ -68,7 +68,7 @@ class OAuth2Authorize(models.Model): user_document = models.ForeignKey(UserDocument) access_token = models.CharField(max_length=255, default=generate_uuid) code = models.CharField(max_length=255, default=generate_uuid) - creation_date = models.DateTimeField(auto_now=True) + creation_date = models.DateTimeField(auto_now_add=True) def __repr__(self): return 'OAuth2Authorize for document %r' % self.user_document @@ -79,4 +79,4 @@ class OAuth2TempFile(models.Model): client = models.ForeignKey(OAuth2Client) document = models.ForeignKey(Document) filename = models.CharField(max_length=512) - creation_date = models.DateTimeField(auto_now=True) + creation_date = models.DateTimeField(auto_now_add=True) -- 2.14.2