sql - How to convert a CharField to Datetime Field in Python(Django)? -


i have charfield in model database. want convert charfield column real datetime django format. have insert query

test.objects.create(voice=m.voice, size=m.size, start_time=get_time.get('min_time'),) 

i create function solve it, not sure how it. please help.

i think directly change character field datetime field hard. need 1 one.

  1. create new datetime column e.g. start_datetime
  2. create script convert start_time string datetime object.
  3. edit code depend on start_time
  4. delete start_time column

this example conversion string datetime code.

import time obj in test.objects.all():     obj.start_datetime = time.strptime(obj.start_time, "%d %b %y")     obj.save() 

you might want read python time library.


Comments

Popular posts from this blog

javascript - Using jquery append to add option values into a select element not working -

Android soft keyboard reverts to default keyboard on orientation change -

Rendering JButton to get the JCheckBox behavior in a JTable by using images does not update my table -