Django aplikazioetarako New York Times estiloko data-artxibo sistema konfiguragarria.
Project description
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 toAUTH_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'
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:
- Have a Date or DateTime field (matching the name in settings).
- 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 using django-cs-archive namespace
return reverse('django_cs_archive:detail', kwargs={
'year': self.pub_date.year,
'month': self.pub_date.strftime('%m'),
'day': self.pub_date.strftime('%d'),
'slug': self.slug,
})
Usage
Once configured, the following URLs will be automatically available (assuming you used the news/ 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.htmltemplates/django_cs_archive/archive_month.htmltemplates/django_cs_archive/archive_day.htmltemplates/django_cs_archive/archive_detail.html
License
MIT License.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_cs_archive-1.0.0.tar.gz.
File metadata
- Download URL: django_cs_archive-1.0.0.tar.gz
- Upload date:
- Size: 8.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
46398de74fdcd223e717b365688ebd8f1175d43c8af45497949b81b45965eabb
|
|
| MD5 |
107444d2f2cd760ddd947e4afabd0117
|
|
| BLAKE2b-256 |
4f50fc829de23ba8ba048cdeb17f10952b76d74b8e089b308807227bf19fdf33
|
Provenance
The following attestation bundles were made for django_cs_archive-1.0.0.tar.gz:
Publisher:
python-publish.yml on uloidi/django-cs-archive
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_cs_archive-1.0.0.tar.gz -
Subject digest:
46398de74fdcd223e717b365688ebd8f1175d43c8af45497949b81b45965eabb - Sigstore transparency entry: 730989618
- Sigstore integration time:
-
Permalink:
uloidi/django-cs-archive@1bca78a83ea869887f2a3ae67ced10fc63e81823 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/uloidi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@1bca78a83ea869887f2a3ae67ced10fc63e81823 -
Trigger Event:
release
-
Statement type:
File details
Details for the file django_cs_archive-1.0.0-py3-none-any.whl.
File metadata
- Download URL: django_cs_archive-1.0.0-py3-none-any.whl
- Upload date:
- Size: 9.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ca44893f029c4f1da0dc5c3b19af45c39cefb534979e37fc9497d8c940286cc9
|
|
| MD5 |
0446a6400822679b872b42631949943e
|
|
| BLAKE2b-256 |
007a0d1ddd1438bcedefc50921975ff7b6f741786398bf7fff706efa8ef255e4
|
Provenance
The following attestation bundles were made for django_cs_archive-1.0.0-py3-none-any.whl:
Publisher:
python-publish.yml on uloidi/django-cs-archive
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
django_cs_archive-1.0.0-py3-none-any.whl -
Subject digest:
ca44893f029c4f1da0dc5c3b19af45c39cefb534979e37fc9497d8c940286cc9 - Sigstore transparency entry: 730989621
- Sigstore integration time:
-
Permalink:
uloidi/django-cs-archive@1bca78a83ea869887f2a3ae67ced10fc63e81823 -
Branch / Tag:
refs/tags/1.0.0 - Owner: https://github.com/uloidi
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
python-publish.yml@1bca78a83ea869887f2a3ae67ced10fc63e81823 -
Trigger Event:
release
-
Statement type: