Skip to main content

djangocms-blog-expiry-date

djangoCMS blog expiry date logo

Extension for django CMS blog that adds an optional expiry date per post.


Installation

  1. Install the package:

    python3 -m pip install djangocms-blog-expiry-date
    
  2. Add it to INSTALLED_APPS:

        "djangocms_blog_expiry_date",
    
  3. Run migrations:

    python3 manage.py migrate djangocms_blog_expiry_date
    
  4. Update your templates to load the templatetag, and use it to test if the post is expired

    {% load djangocms_blog_expiry_date_tags %}
    
    {% post_expiry_expired post as post_expired %}
    {% if post_expired %}
      {# show a notice, or hide booking links, etc. #}
    {% endif %}
    

Behaviour

post_expiry_expired (Python)

djangocms_blog_expiry_date.utils.post_expiry_expired(post) returns:

  • True if an extension linked to post has _meta.app_label == 'djangocms_blog_expiry_date' and is_expired() is True for that instance.
  • False if post is None, there is no such extension, expiry_date is empty, or the date is still in the future.

Extensions whose model belongs to another app are ignored (so several extension types can coexist on the same post).

Template tag

Load the tag library, assign the result, then branch (simple tags must use the as form to work inside {% if %}):

{% load djangocms_blog_expiry_date_tags %}

{% post_expiry_expired post as post_expired %}
{% if post_expired %}
  {# show a notice or hide booking links, etc. #}
{% endif %}

This uses the same rules as post_expiry_expired() above.

Calling is_expired on a single extension

If you know the extension is this app’s model (e.g. only one extension type), you can still use:

{% with ext=post.extension.first %}
  {% if ext and ext.is_expired %}
    …
  {% endif %}
{% endwith %}

Optional settings

Multisite

With BLOG_MULTISITE = True, the app registers a get_sites function on the user model (see apps.py), using django CMS global page permissions.


Tests

Install test dependencies using the following commands:

python3 -m venv .venv
. .venv/bin/activate
python3 -m pip install -e ".[test]"

Launch tests using these commands:

. .venv/bin/activate
pytest

Metadata

Release files for djangocms-blog-expiry-date 0.0.3

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

Source distribution (sdist)

Source distribution for djangocms-blog-expiry-date 0.0.3
File Size Uploaded
djangocms_blog_expiry_date-0.0.3.tar.gz 23.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for djangocms-blog-expiry-date 0.0.3
File Interpreter ABI Platform
djangocms_blog_expiry_date-0.0.3-py3-none-any.whl Python 3 none any Details

Total release size: 48.3 kB

Release files / djangocms_blog_expiry_date-0.0.3.tar.gz

Download URL djangocms_blog_expiry_date-0.0.3.tar.gz
Size 23.0 kB
Tags Source
SHA-256 checksum
How to use checksums
bafcd543c43613d20c6fe6cb7503542f464126c9fbf94822b1c8d9eb12f077dd
BLAKE2b-256 checksum
How to use checksums
212e95a866419e99c27f20c32b9af7ff25fa2dcebaa0f3062baf520db76d8656
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.2

Release files / djangocms_blog_expiry_date-0.0.3-py3-none-any.whl

Download URL djangocms_blog_expiry_date-0.0.3-py3-none-any.whl
Size 25.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
88a96cf956a8ee9b98af36603d35dad6c2bc91a5db6efc2e2ee35e8762fbb02c
BLAKE2b-256 checksum
How to use checksums
1b443d5d46abee61e5800dd8ca9a76efe0889fbb6dc28daaf1d47bded23ace6a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.11.2

Release history Release notifications | RSS feed

This release

0.0.3 This release

2 release files

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