Monkey-patching the slugify() function for better internationalization support

Monkey patch or guerrilla patch is a piece of code that extends or modifies another piece of code at runtime. It is not recommended to use monkey patch often; however, sometimes, it is the only possible way to fix a bug in third-party modules without creating a separate branch of the module. Also, monkey patching might be used to prepare functional or unit tests without using complex database or file manipulations. In this recipe, you will learn how to exchange the default slugify() function with the one from the third-party awesome-slugify module, which handles German, Greek, and Russian words smarter and allows to create customized slugs for other languages. As a ...

Get Django: Web Development with Python now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.