Managing job descriptions at scale can be challenging — especially when you want them to be SEO-optimized, formatted cleanly in HTML, and written in a consistent tone. In this post, I’ll show you how I automated the process using:
- A custom Django management command to reset existing HTML content.
- An OpenAI API integration that rewrites job descriptions in Dutch, optimized for search engines, and formats them in clean HTML.
🔧 Step 1: Create a Django Command to Reset HTML Fields
Before rewriting the job descriptions, we need to clear the html_text
field in all job records.
In your Django app (in this case, permanentjob
), create the following file:
permanentjob/
└── management/
└── commands/
└── reset_job_html.py
Make sure to add __init__.py
files in management/
and commands/
.
Then add this code:
from django.core.management.base import BaseCommand
from permanentjob.models import PermanentJob
class Command(BaseCommand):
help = "Reset the 'html_text' field of all PermanentJob entries to an empty string."
def handle(self, *args, **kwargs):
jobs = PermanentJob.objects.all()
updated_count = jobs.update(html_text='')
self.stdout.write(self.style.SUCCESS(f"Successfully reset html_text for {updated_count} jobs."))
Now you can reset all descriptions with:
python3 manage.py reset_job_html
⚙️ Step 2: Use OpenAI API to Rewrite Job Descriptions in Dutch
We use the OpenAI Chat API to take raw job descriptions and return fully rewritten, SEO-friendly HTML content. The model is instructed to always write in Dutch, follow allowed HTML tags, and remove unwanted characters like ⚠
.
Here’s the Python function used to call the API:
def optimaliseer_vacaturetekst(self, page):
completion = self.client.chat.completions.create(
model="gpt-3.5-turbo",
messages=[
{
"role": "system",
"content": (
"Je bent een ervaren SEO-copywriter gespecialiseerd in het herschrijven van vacatureteksten. "
"Je taak is om de meegeleverde vacaturetekst te herschrijven in het Nederlands, geoptimaliseerd voor zoekmachines (SEO). "
"Gebruik relevante zoekwoorden, duidelijke taal, concrete cijfers (zoals jaren ervaring), en unieke inhoud die aantrekkelijk is voor werkzoekenden.\n\n"
"- Verwijder ongebruikelijke of speciale symbolen (zoals ⚠, ❗, ❌, ✅) en vervang ze waar nodig door realistische data (bijv. '5+ jaar ervaring').\n"
"- Zorg voor correcte spelling, grammatica en zinsbouw in het Nederlands.\n"
"- Lever de output aan in correct geformatteerde HTML met alleen de volgende toegestane tags: "
"'hr', 'b', 'p', 'em', 'strong', 'ul', 'ol', 'li', 'br', 'div', 'h3', 'h4', 'blockquote', 'span', 'pre'.\n"
"- Geen inline CSS of andere HTML-tags gebruiken.\n\n"
"Houd een professionele, wervende en duidelijke toon aan, geschikt voor gebruik op een vacatureplatform."
)
},
{
"role": "user",
"content": page.description
}
]
)
This ensures all job descriptions are:
- SEO-friendly
- Professionally written in Dutch
- Formatted in valid HTML
- Cleaned of odd symbols like ⚠
🚀 Putting It Together
Now, your workflow is simple:
- Run this to clear old HTML content:
python3 manage.py reset_job_html
- Then trigger your OpenAI-based script to rewrite each job description.
🧠 Final Thoughts
With this setup, you can automate the boring part of content optimization and focus on the things that really matter: publishing clear, attractive job listings that rank and convert.
Let me know if you'd like to see the follow-up: how to batch rewrite all jobs automatically using another Django command.
Comments
Post a Comment