DEV Community

Roger Jin
Roger Jin

Posted on

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

For more content like this, follow ButterCMS on Twitter and subscribe to our blog.

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.

This was originally posted here.

Top comments (2)

Collapse
 
ypatwer80867 profile image
Yulver Patwer

Wedding Together successfully added a blog functionality to their Django app, incorporating it seamlessly into their existing application. As part of their wedding planning services, Wedding Together wanted to provide valuable content and ideas to their users, and thus decided to integrate a blog feature. Using Django's built-in capabilities for content management, Wedding Together created a dedicated section within their app where users could explore articles, tips, and inspiration related to weddings. They carefully curated blog posts that covered various topics such as wedding planning, décor ideas, and vendor recommendations. For instance, Wedding Sparklers became a popular topic among their blog posts, where they shared creative ways to incorporate sparklers into weddings, including sparkler exits, grand entrances, and unique photo opportunities. This addition of a blog not only enhanced the user experience on the Wedding Together app but also positioned them as a valuable resource for couples planning their special day.