'''Following those steps:'''
1 - creating a minimal model example including a DurationField
{{{
class Foo(models.Model):
bar = models.DurationField()
}}}
2 - migrate the new model
{{{
$ python manage.py makemigrations AppName
$ python manage.py migrate
}}}
3 - then check the type of the 'bar' DB column related to the 'bar'
DurationField on the 'appname_foo' generated table
{{{
\d appname_foo
}}}
=> The datatype associated to the bar column is not interval as expected
but float
--
Ticket URL: <https://code.djangoproject.com/ticket/26053>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* needs_better_patch: => 0
* needs_tests: => 0
* needs_docs: => 0
Comment:
Hi benjellounayoub,
I couldn't reproduce against PostgreSQL 9.3 and 9.3 on Ubuntu with Django
1.9.1 and master using a [https://github.com/charettes/django-
ticketing/commit/b5ddf8554d41d23474f48ae3bf156af5f0f0b9ca similar test
application].
{{{
\d ticket_26053_foo;
Table "public.ticket_26053_foo"
Column | Type | Modifiers
--------+----------+---------------------------------------------------------------
id | integer | not null default
nextval('ticket_26053_foo_id_seq'::regclass)
bar | interval | not null
Indexes:
"ticket_26053_foo_pkey" PRIMARY KEY, btree (id)
}}}
Can you confirm the generated migration's `CreateModel` operation used a
`models.DurationField()` for its `'bar'` field?
--
Ticket URL: <https://code.djangoproject.com/ticket/26053#comment:1>
Comment (by benjellounayoub):
No, unfortunately it's not the case
For the following model
{{{
class Foo(models.Model):
bar = models.DurationField()
}}}
I have the following CreateModel in the generated migrations
{{{
...
operations = [
migrations.CreateModel(
name='Foo',
fields=[
('id', models.AutoField(auto_created=True,
primary_key=True, serialize=False, verbose_name='ID')),
('bar', models.FloatField(blank=True, default=0,
null=True)),
],
...
}}}
Can you test it with the 9.4 postgreSQL version instead of the 9.3 ? it's
maybe related to this part ...
--
Ticket URL: <https://code.djangoproject.com/ticket/26053#comment:2>
* status: new => closed
* resolution: => worksforme
Comment:
Can you double check you didn't make a mistake (i.e. delete the migration
and re-run `makemigrations`)? It's unthinkable to me that Django would
transform `DurationField()` to `FloatField(blank=True, default=0,
null=True))`.
--
Ticket URL: <https://code.djangoproject.com/ticket/26053#comment:3>
Comment (by benjellounayoub):
Sorry but there is no mistake at all, i can reproduce the issue again and
again
--
Ticket URL: <https://code.djangoproject.com/ticket/26053#comment:4>
* status: closed => new
* resolution: worksforme =>
--
Ticket URL: <https://code.djangoproject.com/ticket/26053#comment:5>
Comment (by benjellounayoub):
Replying to [comment:1 charettes]:
I think you are using the Django's version 1.10.dev for your test and not
the 1.9
> Hi benjellounayoub,
>
> I couldn't reproduce against PostgreSQL 9.3 and 9.3 on Ubuntu with
Django 1.9.1 and master using a [https://github.com/charettes/django-
ticketing/commit/b5ddf8554d41d23474f48ae3bf156af5f0f0b9ca similar test
application].
>
> {{{
> \d ticket_26053_foo;
> Table "public.ticket_26053_foo"
> Column | Type | Modifiers
>
--------+----------+---------------------------------------------------------------
> id | integer | not null default
nextval('ticket_26053_foo_id_seq'::regclass)
> bar | interval | not null
> Indexes:
> "ticket_26053_foo_pkey" PRIMARY KEY, btree (id)
> }}}
>
> Can you confirm the generated migration's `CreateModel` operation used a
`models.DurationField()` for its `'bar'` field?
--
Ticket URL: <https://code.djangoproject.com/ticket/26053#comment:6>
Comment (by timgraham):
Could you please provide a sample project with steps to reproduce it? For
the provided model, I'm still seeing this for the 1.9 branch:
{{{
migrations.CreateModel(
name='Foo',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True,
serialize=False, verbose_name='ID')),
('bar', models.DurationField()),
],
),
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/26053#comment:7>
Comment (by charettes):
@benjellounayoub, the migration I commited was generated with the master
branch because I first reproduced against 1.9 and tried against master to
see if it was fixed.
I managed to reproduce against Django [https://asciinema.org/a/33254
again]. Please let me know if I missed something.
Are you sure you don't have any third party app that might have interfered
and you are really using the `django.db.models.DurationField`?
--
Ticket URL: <https://code.djangoproject.com/ticket/26053#comment:8>
* status: new => closed
* resolution: => worksforme
--
Ticket URL: <https://code.djangoproject.com/ticket/26053#comment:9>