Join 5000+ subscribers and get tips for engineering leaders once a month

Back to all posts

How Wedding Together added a blog to their Django app in 5 minutes

Posted by Roger Jin on June 29, 2017

This is guest post written by Adam Yala, a Python and Django developer at Wedding Together.  Find him on Github.

Our Problem

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.

Our Requirements

  • We don’t want to worry about SEO. It should come built-in.
  • We want to put whatever code we pull from GitHub to live at weddingtogether.co/blog without any NGINX/Apache witchcraft.
  • We don’t want to be editing HTML files or writing code every time a content change is made.

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:

  • a separate set of SASS stylesheets just for this blog.
  • to spend time managing security updates.
  • to mess with our current configuration.
  • to role our own solution.

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.

Our Options

Self Managed

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:
    • Has all the bells and whistles out of the box. We don’t want to deal with things like SEO and meta what-not.
    • Hackable if we want to make modifications
    • Simple non-developer interface for making blog posts
    • “Free” (explained below)
  • Cons
    • Requires us to manage and maintain another application

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.

Managed For Us

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.

Our Choice

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.

Editor's note: Check out our Django or Python docs to test out adding a blog to your application.

Get started now

Sign up with Google Sign up with Github
or