We’re python developers and we want to add a blog to Wedding Together. Wedding Together is a mobile app that allows wedding guests to share photos they take at weddings. Adding a blog to a website is a problem as old as the internet. If we find ourselves reinventing the wheel, we’re probably doing it wrong. I could discuss building our own blogging system from scratch, but there are already plenty of articles on how to do that.
One requirement makes a clear separation between all the paths we can take. We want to protect and improve our development processes.
If we don’t want:
Our option is to pick a managed solution. We’ll go over those second. If we’re ok with some of those things, then we have two self-managed options.
The two most popular python web frameworks are Django and Flask. Wedding Together’s backend is built with Django, so we’ll start there. A few Google searches later we find Mezzanine to be the most active Django blog project. If the best option involves the downside of creating an additional application to take care of, we might as well look up options in Flask. The two most used options are flask-blog and Flask-Blogging. flask-blog hasn’t been updated in 3 years. Flask-Blogging is our “Mezzanine level” blog option but in Flask. Both Mezzanine and Flask-Blogging have the following pros and cons:
Pros:
Cons
Depending on how your infrastructure is setup, adding another application could be as simple as pip installing on a server or as difficult as adding another machine to your already growing architecture.
Most web/software companies have one resource that they’ll never get enough of, developer time. Mezzanine and Flask-Blogging are “free” if you don’t consider developer time. If you account for developer time in implementing these options, they are among the most expensive options you could pick.
Let’s look at a managed option that is almost free in a sense of developer time. ButterCMS is a managed blog option with the most developer friendly API possible. I’ve tried out half a dozen blog API options and ButterCMS is truly the easiest and most simple.
We log into the interface on their site to write a blog post.
We install the python module.
pip install buttercms-python
We pull our blog post:
from butter_cms import ButterCMS
def blog(request): client = ButterCMS('your-token-goes-here') posts = client.posts.all() return render(request, 'blog.html', {'posts': posts})
Put it in our template:
{% for post in posts %} <h1>{{ post.title }}</h1>
<p>{{ post.body|safe }}</p>{% endfor %}
And that’s it!
My example is missing couple tiny tweaks to make Django play perfectly their API, all of which are covered here in their docs.
Spinning up an instance of Mezzanine or Flask-Blogging is a definite possibility, but took me more hours than I’d like to admit to get going. I’m also not exactly looking forward to dealing with another database and Django application as time goes on.
Adding a managed option like ButterCMS took me about 5 minutes and I know I’ll never have to mess with it again.
Most of the other blogging APIs are filled with cryptic terms like “blog modelling” or having to navigate a “content delivery API” vs a “content management API”. ButterCMS touts a simple and straight forward system that lets you focus on building your company and products.
This article was originally published on the ButterCMS blog. ButterCMS is a hosted API-based blog engine that lets you build CMS-powered apps.