Skip to main content

Django Admin Timestamps

Show human readable created/modified dates and/or times in the django.contrib.admin changelist for models that track the moment of creation and updates.

Usage

First you will need to have a model that tracks the moment of creation and modification. The barebones example for that is:

from django.db import models

class TimestampedItem(models.Model):
    created = models.DateTimeField('created', auto_now_add=True)
    modified = models.DateTimeField('modified', auto_now=True)

Or, if you are using django-extensions:

from django_extensions.db.models import TimeStampedModel

class TimestampedItem(TimeStampedModel):
    pass

Now it’s time to register this model with Django’s admin site.

Create a admin class, just like you’d usually do, but make it extend TimestampedAdminMixin as well as any other base admin class you use:

from django.contrib import admin
from models import TimestampedItem
from admintimestamps import TimestampedAdminMixin

class TimestampedAdmin(TimestampedAdminMixin, admin.ModelAdmin):
    pass

admin.site.register(TimestampedItem, TimestampedAdmin)

That’s it!

https://bitbucket.org/jaap3/django-admin-timestamps/raw/tip/img/screenshot.png

Configuration

If the names of you timestamp fields aren’t created and modified but for example created_at and modified_at you’ll need to do a tiny bit of configuration in the model admin class:

class TimestampedAdmin(TimestampedAdminMixin, admin.ModelAdmin):
    timestamp_fields = ('created_at', 'modified_at')

You can also use the timestamp_fields tuple to only show one field by only specifying the field you want to show:

class TimestampedAdmin(TimestampedAdminMixin, admin.ModelAdmin):
    timestamp_fields = ('modified',)

Changelog for django-admin-timestamps

1.2 (2014-09-29)

  • Dropped support for Python < 2.6

  • Dropped support for Django < 1.4

  • Verified support for up to Django 1.7

  • Added support for Python 3

1.1.1 (2013-07-01)

  • Handle None values properly

1.1 (2012-02-21)

  • Just displaying one timestamp field is now possible.

  • Proper handling of date fields.

1.0.1 (2011-10-11)

  • Fixed setup.py to include the compat subpackage

1.0.0 (2011-10-07)

  • Initial release

Metadata

Release files for django-admin-timestamps 1.2

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-admin-timestamps 1.2
File Size Uploaded Provenance Actions
django-admin-timestamps-1.2.zip 16.8 kB Without provenance Details for django-admin-timestamps-1.2.zip

Release files / django-admin-timestamps-1.2.zip

Download URL django-admin-timestamps-1.2.zip
Size 16.8 kB
Tags Source
SHA-256 checksum
How to use checksums
d34b4679fd70c6d22d325e8695b503fccefa54e690e19a884025e1b5d80ac495
BLAKE2b-256 checksum
How to use checksums
1a49a9b6c78262a7497ec96e058bfbf1a5970371ff146b14cbf1ce5f49726aee
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-admin-timestamps 1.2

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page