Managing feincms3 websites through the API/CLI
Do you know how it is when you have to do something small and annoying, and instead you spend hours or days building a whole thing to automate the thing? This happens to me more and more often these days.
The great development in our beautiful new world is that now code is no longer always the limiting factor. I had been thinking for years about what an API for feincms3 should look like, but now I could finally just throw a prototype together, iterate on it, and presto – I have something real people can do actual work with.
Yes, the best code is no code at all, I still agree. However, as someone who tries to get problems solved, the best code is code which solves the problems I want to solve.
Configuring feincms3-api
Since feincms3 and django-content-editor ship no concrete models, the code has to be somewhat flexible.
It reuses the admin forms and the admin permissions – what’s allowed in the Django administration interface is allowed through the API. Nothing more.
Here’s a real example:
# app/content_api.py
from feincms3_api.api import ContentAPI
from feincms3_api.resources import ObjectResource, PageResource
from app.articles.models import Article, Category
from app.pages.models import Page
from app.team.models import Member
content_api = ContentAPI()
content_api.register(PageResource(Page))
content_api.register(ObjectResource(Article))
content_api.register(ObjectResource(Category))
content_api.register(ObjectResource(Member))
# app/urls.py
from app.content_api import content_api
urlpatterns = [
...
path("api/content/", content_api.as_api().urls),
]
The ObjectResource automatically allows editing the object itself and everything included via admin inlines such as CMS plugins (rich text, images, etc.). The PageResource builds on the TreeResource because it also understands working with trees.
File uploads are also supported transparently; files are uploaded to a staging area and then moved when linked into a real file field.
Authentication currently uses short-lived tokens, either in read or in read-write mode. Those tokens can either be generated using a management command or directly in the Django admin.
Agents and skills
The feincms3-api-cli package ships a Python-based CLI which knows how to handle authentication with different sites and nicely wraps the server-side API. CLIs are especially nice because agents work well with them. I’m not ruling out adding MCP support, but that’s more involved and requires ASGI (when using the mcp library), and a CLI works just as well for technical users. If you think I’m implying that feincms3-api might not be ready for end users who aren’t at least somewhat well versed technically, then that might be correct too.
The feincms3-api-cli project ships several skills which solve real problems for us:
feincms3-dummy-content allows filling the CMS with better content than just copy-pasting lorem ipsum everywhere. How often have I heard the phrase “I can’t fill in content as long as the website is still in the process of being developed”, and how often have I said “I can’t finish the development without seeing real content in there”. The solution was always to write some limited content by hand. A time-consuming additional step which nobody paid for and nobody appreciated. And it wasn’t fun either. The skill looks at the structure of the website and what the website should be about, and generates some content. I really hope though that all of the generated content will be deleted once the real work starts.
feincms3-review reviews website contents for errors, broken links, inconsistent terminology, etc. It just helps with improving what we have. The idea is not to let the agent change everything into AI slop, but to give real hints about improvements which editors could make.
feincms3-translate supports translating a whole page tree, or just a few models, or a subset. How often have I seen designs for multilingual sites where “About us” and “Über uns” fit nicely, but “À propos de nous” didn’t. Or even better, “Students” vs “Schülerinnen und Schüler”1. I don’t want to dunk on German and French (both of which I like), it’s just a fact that some words or expressions are so much longer, and designs which work well in one language completely fall apart in another. In a way this is a variant of the dummy content problem above, but even more important when developing a new website.
Where it stands
We have successfully used the tool for updating legal documents on websites, for applying SEO improvements to websites, for translating content into other languages and for showing all possible variants of a particular graphing plugin. If you’re using django-content-editor it’s ready for you. Here are the docs if you want to get started.
In some places we can use Schüler*innen or Schüler:innen, but in school contexts that’s not an accepted way of spelling these words yet. ↩