digital hedgehog illustration

SqlAlchemy

Hero

How to Manage Slugs for Database Entities with Flask and SqlAlchemy

This tutorial is about the technique I use to manage slugs.

Introduction

If you have ever tried to create a blog-like application or something that needs unique slugs, you might run on two problems:

  • How to not repeat yourself? Imagine you have articles, categories, and products, and they all need slugs.
  • What to do in a case where two or more entities have the same names used to generate slug?

Written by StefanJeremic on Apr 11, 2022