Hi,

Here is my model:
class Flow(models.Model):
    ref = models.CharField(max_length=32)
    state = models.ForeignKey(State)
    flow_type = models.ForeignKey(Type)
    created = models.DateTimeField(db_index=True, auto_now_add=True)
    modified = models.DateTimeField(db_index=True, auto_now=True)
    version = models.IntegerField()
    def __str__(self):
        return str(self.id)

Here is my test.py file:
import warnings
warnings.filterwarnings(
    'error', r"DateTimeField .* received a naive datetime",
    RuntimeWarning, r'django\.db\.models\.fields')


In settings.py:
TIME_ZONE = 'Europe/London'
USE_TZ = True

Here is what happens when I run the test script:
>python manage.py test flow
Creating test database for alias 'default'...
Traceback (most recent call last):
  File "manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "C:\landy\lib\site-packages\django\core\management\__init__.py", 
line 385
, in execute_from_command_line
    utility.execute()
  File "C:\landy\lib\site-packages\django\core\management\__init__.py", 
line 377
, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File 
"C:\landy\lib\site-packages\django\core\management\commands\test.py", lin
e 50, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "C:\landy\lib\site-packages\django\core\management\base.py", line 
288, in
 run_from_argv
    self.execute(*args, **options.__dict__)
  File 
"C:\landy\lib\site-packages\django\core\management\commands\test.py", lin
e 71, in execute
    super(Command, self).execute(*args, **options)
  File "C:\landy\lib\site-packages\django\core\management\base.py", line 
338, in
 execute
    output = self.handle(*args, **options)
  File 
"C:\landy\lib\site-packages\django\core\management\commands\test.py", lin
e 88, in handle
    failures = test_runner.run_tests(test_labels)
  File "C:\landy\lib\site-packages\django\test\runner.py", line 147, in 
run_test
s
    old_config = self.setup_databases()
  File "C:\landy\lib\site-packages\django\test\runner.py", line 109, in 
setup_da
tabases
    return setup_databases(self.verbosity, self.interactive, **kwargs)
  File "C:\landy\lib\site-packages\django\test\runner.py", line 299, in 
setup_da
tabases
    serialize=connection.settings_dict.get("TEST_SERIALIZE", True),
  File "C:\landy\lib\site-packages\django\db\backends\creation.py", line 
374, in
 create_test_db
    test_flush=True,
  File "C:\landy\lib\site-packages\django\core\management\__init__.py", 
line 115
, in call_command
    return klass.execute(*args, **defaults)
  File "C:\landy\lib\site-packages\django\core\management\base.py", line 
338, in
 execute
    output = self.handle(*args, **options)
  File 
"C:\landy\lib\site-packages\django\core\management\commands\migrate.py",
line 160, in handle
    executor.migrate(targets, plan, fake=options.get("fake", False))
  File "C:\landy\lib\site-packages\django\db\migrations\executor.py", line 
63, i
n migrate
    self.apply_migration(migration, fake=fake)
  File "C:\landy\lib\site-packages\django\db\migrations\executor.py", line 
97, i
n apply_migration
    migration.apply(project_state, schema_editor)
  File "C:\landy\lib\site-packages\django\db\migrations\migration.py", line 
107,
 in apply
    operation.database_forwards(self.app_label, schema_editor, 
project_state, ne
w_state)
  File 
"C:\landy\lib\site-packages\django\db\migrations\operations\fields.py", l
ine 131, in database_forwards
    schema_editor.alter_field(from_model, from_field, to_field)
  File "C:\landy\lib\site-packages\django\db\backends\schema.py", line 509, 
in a
lter_field
    self._alter_field(model, old_field, new_field, old_type, new_type, 
old_db_pa
rams, new_db_params, strict)
  File "C:\landy\lib\site-packages\django\db\backends\schema.py", line 612, 
in _
alter_field
    new_default = self.effective_default(new_field)
  File "C:\landy\lib\site-packages\django\db\backends\schema.py", line 183, 
in e
ffective_default
    default = field.get_db_prep_save(default, self.connection)
  File "C:\landy\lib\site-packages\django\db\models\fields\__init__.py", 
line 62
7, in get_db_prep_save
    prepared=False)
  File "C:\landy\lib\site-packages\django\db\models\fields\__init__.py", 
line 12
86, in get_db_prep_value
    value = self.get_prep_value(value)
  File "C:\landy\lib\site-packages\django\db\models\fields\__init__.py", 
line 12
78, in get_prep_value
    RuntimeWarning)
RuntimeWarning: DateTimeField Flow.created received a naive datetime 
(2014-11-19
 12:28:38.831258) while time zone support is active.

What on earth is causing this "naive datetime" warning?

Thanks

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/9483e04e-242a-4252-a707-f51e6763ef2c%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to