Skip to main content

django-cs-archive

A date-based archiving system (YYYY/MM/DD) for Django applications.

This package wraps Django's powerful generic date views into a plug-and-play solution. It follows the "Convention over Configuration" philosophy: just add a few lines to your settings.py, and you're ready to go.

Features

  • 📅 Full Hierarchy: Year, Month, and Day views.
  • ⚙️ Centralized Configuration: Managed via settings.py, similar to AUTH_USER_MODEL.
  • 🔌 Plug-and-play: No need to write complex views or URL patterns manually.
  • 🐍 Compatibility: Supports Django 3.2+.

Installation

Install via pip:

pip install django-cs-archive

Configuration

This is the most important part. Follow these three simple steps:

1. settings.py

Add the app to your installed apps and define which model you want to archive.

INSTALLED_APPS = [
    # ... other apps
    'django_cs_archive',
]

# REQUIRED: The model to be managed by the archive
# Format: 'app_label.ModelName'
CS_ARCHIVE_MODEL = 'blog.Article' 

# OPTIONAL: The name of the date/datetime field in your model
# Defaults to 'publish_date' if not set.
CS_ARCHIVE_DATE_FIELD = 'pub_date'

# OPTIONAL: Filters to apply to the model queryset.
# Specified as a Python dictionary (or a JSON string representing a dictionary).
# Values can also be callables for dynamic evaluation (e.g. settings.SITE_ID).
CS_ARCHIVE_FILTERS = {
    'status': 'published',
    'is_public': True,
    'sites': lambda: settings.SITE_ID,
}
# Or as a JSON string:
# CS_ARCHIVE_FILTERS = '{"status": "published", "is_public": true}'

2. urls.py

Include the archive URLs in your project's main URL configuration. You can choose any prefix you like (e.g., news/, archive/, blog/).

from django.urls import path, include

urlpatterns = [
    # ...
    path('archive/', include('django_cs_archive.urls')),
]

3. Prepare your Model (models.py)

Your model (defined in CS_ARCHIVE_MODEL) must satisfy at least two requirements:

  1. Have a Date or DateTime field (matching the name in settings).
  2. Have a Slug field (named slug) to generate unique URLs.

It is highly recommended to add the get_absolute_url method to easily generate links in your templates:

from django.db import models
from django.urls import reverse

class Article(models.Model):
    title = models.CharField(max_length=200)
    slug = models.SlugField(unique_for_date='pub_date') # Important for data integrity
    pub_date = models.DateTimeField()
    content = models.TextField()

    def get_absolute_url(self):
        # Generate the URL 
        return reverse('detail', kwargs={
            'slug': self.slug,
        })

Usage

Once configured, the following URLs will be automatically available (assuming you used the archive/ prefix):

  • /archive/ -> The year list.
  • /archive/2024/ -> All months with articles from 2024.
  • /archive/2024/03/ -> All days with articles March 2024.
  • /archive/2024/03/15/ -> All articles from that specific day.

Customization (Templates)

The package has templates that extend your "base.html" file and uses the {% block content %} block to show the content. To customize the look and feel, create the following files in your project's templates directory:

  • templates/django_cs_archive/archive_year.html
  • templates/django_cs_archive/archive_month.html
  • templates/django_cs_archive/archive_day.html
  • templates/django_cs_archive/archive_detail.html

License

MIT License.

Metadata

Release files for django-cs-archive 1.4.1

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-cs-archive 1.4.1
File Size Uploaded Provenance
django_cs_archive-1.4.1.tar.gz 14.5 kB With provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for django-cs-archive 1.4.1
File Interpreter ABI Platform
django_cs_archive-1.4.1-py3-none-any.whl Python 3 none any Details

Total release size: 36.3 kB

Release files / django_cs_archive-1.4.1.tar.gz

Download URL django_cs_archive-1.4.1.tar.gz
Size 14.5 kB
Tags Source
SHA-256 checksum
How to use checksums
3f6e93e363e4585880de2a87fbe4d9f02c9e17828b6cd0a9ca067764a6ea91de
BLAKE2b-256 checksum
How to use checksums
5862f4c3fbb6ae0170d474683c03b0bac244126086a404ef0834b1398480d205
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Release files / django_cs_archive-1.4.1-py3-none-any.whl

Download URL django_cs_archive-1.4.1-py3-none-any.whl
Size 21.7 kB
Tags Python 3
SHA-256 checksum
How to use checksums
5309c848c50062ce5a96f8e1aaf78adaff83a92854b9f2a19136e1393d62af1f
BLAKE2b-256 checksum
How to use checksums
0cb0d75b0c77475368623437311310af29a23747085f408fddab041869b96771
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

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.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

Security for django-cs-archive 1.4.1

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.

Full provenance

All 2 files in this release have been uploaded with provenance metadata.

Select from 2 files

Attestation for django_cs_archive-1.4.1.tar.gz

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 9, 2026.

Transparency log

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