Django model for automatic timestamps.
- Automatically adds
created_at
andupdated_at
timestamps to your Django models. - Simplifies tracking of creation and modification times of objects.
You can install django-auto-timestamps-model
via pip:
pip install django-auto-timestamps-model
- Install django-auto-timestamps-model using pip.
- Import the AutoTimestampsModel class from this module.
- Inherit the AutoTimestampsModel class in your Django model class.
- The 'created_at' and 'updated_at' fields will be automatically added to your model.
- The 'created_at' field will be set to the current timestamp when a new instance is created.
- The 'updated_at' field will be updated with the current timestamp whenever the model is saved.
Example:
from django.db import models
from django_auto_timestamps_model import AutoTimestampsModel
class YourModel(AutoTimestampsModel, models.Model):
# Your model fields here
Django >= 1.4 and Django <= 4.2
Contributions are welcome! Please feel free to open an issue or submit a pull request.