1

I'm trying to have an immutable field(created_at) and be able to update it(updated_at) without altering the original created_at field. This is a django project if that matters

1 Answer 1

2

Use auto_now and auto_now_add (see documentation).

class Book(models.Model):
    ...
    created_at = models.DateTimeField(auto_now_add=True)
    updated_at = models.DateTimeField(auto_now=True)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.