1

I'm using widgets.AdminSplitDateTime in a create view that is corresponding to a datetime field.

When I try to create the object it gives me the following error:

RemovedInDjango19Warning: Using SplitDateTimeWidget with DateTimeField is deprecated. Use SplitDateTimeField instead.

I have searched the web for an answer about how to use it but I couldn't find anything that works..

I tries to change the widgets.AdminSplitDateTime to forms.SplitDateTimeField and it gave me the following error:

'SplitDateTimeField' object has no attribute 'is_hidden'

can someone help me on figuring out how to use it?

ilse2005
  • 11,189
  • 5
  • 51
  • 75
brad
  • 491
  • 1
  • 9
  • 24
  • 2
    You need to replace `DateTimeField` (i.e. the field, not the widget) with `SplitDateTimeField` – Ludwik Trammer Mar 14 '16 at 10:31
  • you mean to replace the model field? i.e. from models.DateTimeField to SplitDateTimeField ? – brad Mar 14 '16 at 10:37
  • Yes, exactly. That's what the depreciation message suggests you do. – Ludwik Trammer Mar 14 '16 at 10:39
  • when i changed the models.DateTimeField it deleted the corresponding fields from the db.. – brad Mar 14 '16 at 10:46
  • That's just matter of having right migrations. If it is the case that the `makemigrations` command creates for you a migration that deletes the old column and adds a new one (instead of altering it in place) you should create your own correct migration, as described here: http://stackoverflow.com/questions/27385118/change-column-type-with-django-migrations (the bottom "Django 1.7" part of the answer). – Ludwik Trammer Mar 14 '16 at 11:04
  • 2
    @LudwikTrammer `SplitDateTimeField` is a **form** field, not a **model** field. Changing the `DateTimeField` model field to a `SplitDateTimeField` form field and migrating will drop the column from the db. – Alasdair Mar 14 '16 at 11:54
  • @Alasdair You are right. My bad. – Ludwik Trammer Mar 14 '16 at 12:57

0 Answers0