Ticket #483 (closed defect: fixed)

Opened 4 years ago

Last modified 4 years ago

Incorrect behaviour when using "from django.utils.datetime_safe import datetime"

Reported by: frost.baka@… Owned by: andrew
Priority: major Milestone: 0.7.2
Component: migrations Version: 0.7.1
Keywords: Cc:

Description

Code created in migrations seems to improperly import this module, that's why migrate command fails with TypeError?: 'module' object is not callable, because of this:
encoding: utf-8

import datetime
from south.db import db
from south.v2 import SchemaMigration
from django.db import models

class Migration(SchemaMigration):

    def forwards(self, orm):

        # Adding field 'Schoolar.year_out'
        db.add_column('worksnot_schoolar', 'year_out', self.gf('django.db.models.fields.DateTimeField')(default='''datetime(2010, 6, 22, 7, 1, 27, 931899)''', auto_now=True, null=True, blank=True), keep_default=False)

model code:

from django.db import models
from datetime import datetime
from django.utils import datetime_safe
class Schoolar(models.Model):
        year_in=models.DateTimeField(default=datetime.now(),auto_now=True,null=True,blank=True)
        year_out=models.DateTimeField(default=datetime_safe.datetime.now(),auto_now=True,null=True,blank=True)

As for me datetime.datetime works perfectly

Change History

comment:1 Changed 4 years ago by andrew

  • Status changed from new to closed
  • Resolution set to fixed

Ah, it seems the repr() of safe_datetime is a little odd. Fixed by [a5c175042592].

comment:2 Changed 4 years ago by andrew

  • Version changed from unknown to 0.7.1
  • Milestone set to 0.7.2
Note: See TracTickets for help on using tickets.