Home Python Django Datetime objects and literal strings vs variables
Reply: 0

Python Django Datetime objects and literal strings vs variables

user910 Published in July 21, 2018, 1:37 pm

I am transferring some legacy posts into a new Django blog. In my script, I have the following code:

        title=['title'], slug=['slug'], chron_date=['chron_date'],
        clock='23:59:59', content=['content'])

The problem is that the date, time, and datetime fields all refuse to take a variable, or, they all treat the intended variable as a literal string, which generates errors. The only solution I’ve found is the one you see for clock, where I have to hard code a literal string. This means I have to go back through the posts one at a time to manually correct the dates and times.

Questions: Why do the date and time objects work this way? Is this the only workaround, or am I missing something that would allow me to use a variable and loop through all the actual dates and get them imported?


You need to login account before you can post.

About| Privacy statement| Terms of Service| Advertising| Contact us| Help| Sitemap|
Processed in 0.320108 second(s) , Gzip On .

© 2016 Powered by mzan.com design MATCHINFO