OGMagic

Integrations

OG Images for Django

Create an image once and reuse its public URL in your page metadata.

Include a Django template fragment in your page's head and read the saved image URL from the post object. Django's automatic escaping keeps titles, descriptions, and URLs inside their attributes.

Quick Start

1. Create and save your image URL

Get a private API key through email access and set OGMAGIC_API_KEY in your server or terminal environment. Run this request when publishing content, then save the returned url with the page:

Terminal or publishing workflow — Bash/curl
curl https://www.ogmagic.dev/api/images \
  -H "Authorization: Bearer $OGMAGIC_API_KEY" \
  -H "Content-Type: application/json" \
  -d '{"title":"My article","template":"gradient-mesh"}'
# Save the returned url with your content. Keep the API key private.

You can also create an image in the editor and copy its hosted URL. Keep the API key private; the returned image URL is public.

2. Publish it in your Django metadata

Use your saved URL in the example below. Replace any placeholder URL with the creation response's url, or pass it from the stored content field. The dimensions shown are for the default 1200 × 630 image; use the returned dimensions for custom sizes.

templates/includes/social_meta.html — include inside base.html's <head>
{% if post.og_image_url %}
<meta name="description" content="{{ post.excerpt }}" />
<meta property="og:title" content="{{ post.title }}" />
<meta property="og:description" content="{{ post.excerpt }}" />
<meta property="og:type" content="article" />
<meta property="og:image" content="{{ post.og_image_url }}" />
<meta property="og:image:width" content="1200" />
<meta property="og:image:height" content="630" />
<meta name="twitter:card" content="summary_large_image" />
<meta name="twitter:image" content="{{ post.og_image_url }}" />
{% endif %}

💡 Pass a post object with title, excerpt and og_image_url fields from the view, then include "includes/social_meta.html" in the document head. Keep automatic escaping enabled and avoid the safe filter for these fields. Create images in a publishing task or management command, not while rendering the template.

Reference: Django documentation. After deploying, check the page with the OG tag checker.

Why use OGMagic with Django?

⚡

Create once

Repeated identical requests reuse the saved image; social views use no generation credits.

🎨

55+ templates

Professional designs out of the box. Customize with JSON options.

🔑

Email access

Get your API key without a password or profile. Keep it private; share only image URLs.

📱

Every platform

Optimized 1200×630 images that look great on Twitter/X, Facebook, LinkedIn, Discord, and Slack.

Ready to add OG images to your Django app?

Start with 50 new images per 30 days. Get your API key through an email link.

Also works with