In django – is there a default timestamp field for all objects? That is, do I have to explicitly declare a ‘timestamp’ field for ‘created on’ in my Model – or is there a way to get this automagically?
Share
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
No such thing by default, but adding one is super-easy. Just use the
auto_now_addparameter in theDateTimeFieldclass:You can also use
auto_nowfor an ‘updated on’ field.Check the behavior of
auto_nowhere.For
auto_now_addhere.A model with both fields will look like this: