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.
- create new datetime column e.g.
start_datetime
- create script convert
start_time
string datetime object. - edit code depend on
start_time
- 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
Post a Comment