Skip to main content

Blogging made easy

Settings

These should go into your settings.py file.

TCB_BLOG_SETTINGS = {
    'RSS_FEED_TITLE': 'Title of the blog',
    'RSS_FEED_LINK': '/blog/',
    'RSS_FEED_ITEM_DESC_TEMPLATE': 'feed/entries.html',
    'API_CONTRACT_VERSION': '1.0.0',
    'SUPPORTED_FRONTEND_VERSIONS': '>=0.31.0 <0.32.0'
}

If you enable django-upload, you can enforce backend upload policy in settings.py:

UPLOAD_ALLOWED_MIME_TYPES = [
    # Images
    'image/jpeg', 'image/png', 'image/gif',
    # Video
    'video/mp4', 'video/webm', 'video/ogg', 'video/quicktime',
    'video/x-msvideo', 'video/x-ms-wmv', 'video/mpeg',
    'video/3gpp', 'video/3gpp2', 'video/x-matroska', 'video/mp2t',
    # Audio
    'audio/mpeg', 'audio/mp4', 'audio/x-m4a', 'audio/aac',
    'audio/ogg', 'audio/wav', 'audio/x-wav', 'audio/webm',
    'audio/flac', 'audio/x-flac', 'audio/3gpp', 'audio/3gpp2',
    'audio/aiff', 'audio/x-aiff',
]

UPLOAD_ALLOWED_EXTENSIONS = [
    'jpg', 'jpeg', 'png', 'gif',
    'mp4', 'webm', 'ogv', 'mov', 'avi', 'wmv', 'mpeg', 'mpg', 'mkv', 'ts',
    'mp3', 'm4a', 'aac', 'ogg', 'wav', 'flac', 'aif', 'aiff',
]

# Default visibility when clients do not send the public flag
UPLOAD_DEFAULT_PUBLIC = True

Syncing entries to TheCodeBlogs

When an author’s profile has a token and url set (via Django Admin), published blog entries are automatically pushed to the destination site (e.g. https://www.thecodeblogs.com) via a Celery task.

Enabling sync:

Set the author’s token (a DRF token for the destination) and url (on the destination site) in the Django Admin under the author’s Profile record.

How it works:

  • On publish, the entry is POSTed to {url}/api/admin/entries/ with Authorization: Token <token> and an Idempotency-Key header ({entry_id}:{version}).

  • If the destination returns 5xx or a connection error, the task retries up to 5 times with exponential backoff (starting at 60s, capped at 30min). 4xx errors are permanent failures — no retry.

  • Each attempt is recorded in the EntrySync model, visible as a read-only inline on the entry in the admin. The admin also shows a color coded “Sync status” column and a “Mark as not synced (re-sync)” action.

Destination requirements:

The destination must run the same blog app with token authentication enabled, and the blog app mounted at /api/.

Quick start

  1. Add “blog” to your INSTALLED_APPS setting like this

INSTALLED_APPS = [
...
'blog',
]
  1. (Optional) Install django-upload from git and add “upload” to INSTALLED_APPS to enable media uploads

pip install "django-upload @ git+https://git.jamesonnetworks.com/JamesonNetworks/django-upload.git@main"
INSTALLED_APPS = [
...
'blog',
'upload',
]
  1. Include the polls URLconf in your project urls.py like this

path('blog_api/', include('blog.urls')),
  1. Setup a module named ‘backend’

  2. Using celery.py.sample as a guide, setup celery do that tasks will work

  3. Run python manage.py migrate to create the blog models.

  4. Start the development server and visit http://127.0.0.1:8000/admin/

    to create a poll (you’ll need the Admin app enabled).

  5. Visit http://127.0.0.1:8000/blog_api/ to see something.

Running tests locally

The repository includes a standalone pytest configuration.

  1. Install test dependencies:

pip install -r requirements-dev.txt
  1. Run tests from the repository root:

pytest -q

Metadata

Release files for django-tcb-blog 0.33.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-tcb-blog 0.33.1
File Size Uploaded
django_tcb_blog-0.33.1.tar.gz 32.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for django-tcb-blog 0.33.1
File Interpreter ABI Platform
django_tcb_blog-0.33.1-py3-none-any.whl Python 3 none any Details

Total release size: 82.7 kB

Release files / django_tcb_blog-0.33.1.tar.gz

Download URL django_tcb_blog-0.33.1.tar.gz
Size 32.5 kB
Tags Source
SHA-256 checksum
How to use checksums
f371a3b5b36cf5ee519f40da332a540ba108254538cd33afd076f70434d46c3e
BLAKE2b-256 checksum
How to use checksums
313c434ab96208a5a9ecbf6085d0449388892f811b9ccdd8ddcb47d4e3137267
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / django_tcb_blog-0.33.1-py3-none-any.whl

Download URL django_tcb_blog-0.33.1-py3-none-any.whl
Size 50.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
927be13f19b02c4335e1609266ca0e8ac17fa7a6e8475ce3b71b61ef286314e8
BLAKE2b-256 checksum
How to use checksums
0f665f0501fd44d39ab1dbde0a461ce899a1ae87921a426df03c6761a75904fa
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release history Release notifications | RSS feed

0.33.2

2 release files

This release

0.33.1 This release

2 release files

0.32.2

2 release files

0.32.1

2 release files

0.32.0

2 release files

0.31.7

2 release files

0.31.6

2 release files

0.31.5

2 release files

0.31.2

2 release files

0.31.1

2 release files

0.31.0

2 release files

0.11.6

2 release files

0.11.5

2 release files

0.11.4

2 release files

0.11.3

2 release files

0.11.2

2 release files

0.11.1

2 release files

0.11.0

2 release files

0.9.2

2 release files

0.9.1

2 release files

0.9.0

2 release files

0.8.8

2 release files

0.8.7

2 release files

0.8.6

2 release files

0.8.5

2 release files

0.8.4

2 release files

0.8.3

2 release files

0.8.2

2 release files

0.8.1

2 release files

0.8.0

2 release files

0.7

2 release files

0.6

1 release file

0.5

1 release file

0.4

1 release file

0.3

1 release file

0.2

1 release file

0.1

1 release file

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