Learn Python with Talk Python's 270 hours of courses

17 Libraries You Should Be Using in Django

Episode #379, published Fri, Aug 26, 2022, recorded Mon, Aug 22, 2022

Do you write web apps in Django? The framework has come a long way lately with versions 3 and 4 adopting many of the modern Python capabilities (async, for example). But there are so many other libraries and apps that you can use to do more with less code in plugin new functionality. I'm happy to have Christopher Trudeau here on talk Python to take us through his 17 favorite libraries you should be using in Django.

Watch this episode on YouTube
Play on YouTube
Watch the live stream version

Episode Deep Dive

Guest Background

Christopher Trudeau is an experienced Python developer and fractional CTO who specializes in helping teams become more efficient with their software processes. He has authored or co-authored 30+ Python courses, frequently contributing to the Python community. Christopher started his programming journey on an IBM PC Junior, writing his very first program to draw the Batman logo in BASIC. These days, he focuses heavily on Django projects, assists organizations with technical decisions, and teaches others how to streamline their workflows using Python.

What to Know If You're New to Python

If you’re just getting started with Python, here are a few relevant points from this episode to help you follow along:

  • A basic grasp of Python functions, modules, and virtual environments will be really helpful.
  • Understand how Python web frameworks (like Django) abstract database and web server details to help you move quickly.
  • Know that Python’s ecosystem is full of external libraries (installed via pip install) that reduce the need to build from scratch.
  • Familiarity with Python’s testing culture (like pytest or unit tests) will let you apply libraries such as coverage more effectively.

Key Points and Takeaways

  1. Django’s Pluggable Ecosystem
    Django supports a rich ecosystem of reusable apps and packages that “snap in” to extend core functionality. Rather than reinventing the wheel, developers can use tried-and-true libraries to handle authentication, testing, documentation, admin customization, and more. Understanding how to integrate these libraries means writing less code and getting more robust features.

  2. APIs with Django Ninja vs. Django REST Framework
    Creating RESTful APIs is central to many Django apps. Django Ninja offers a modern, Pydantic-driven, type-hinted approach for building APIs quickly with less boilerplate—especially appealing if you enjoy FastAPI-like patterns. Meanwhile, Django REST Framework (DRF) has been the longtime standard, offering extensive features, view sets, and flexible permission handling.

  3. Debugging with Django Debug Toolbar
    The Django Debug Toolbar provides deep insight into performance bottlenecks, database queries, and request/response cycles. It overlays on your web pages during development, helping you see exactly how many queries are run, how long they take, and what could be optimized or cached.

  4. Admin Customization with Django Grappelli and Admin Extra Buttons
    Django’s built-in admin is powerful but not always the most modern-looking. Grappelli re-skins the admin with a cleaner interface, plus adds features like autocomplete fields and better layout. Admin Extra Buttons fills in the gaps when you need custom tasks—like a big “Reset Demo Data” button or any specialized workflow—directly in the admin UI.

  5. Testing and Code Quality with Coverage, PyFlakes, and Tox
    Coverage checks how much of your code is executed during testing, highlighting untested or error-handling paths. PyFlakes is a fast linter for catching unused imports, syntax errors, and code issues. Tox automates testing against multiple Django or Python versions so you know your library or app is solid across different environments.

  6. Documentation with Sphinx
    Sphinx turns your inline docstrings into sleek, navigable documentation sites or PDFs. It supports cross-referencing between functions and classes, auto-generates code references, and can integrate with readthedocs.io for automatic updates on every commit.

  7. Working with Images using Pillow
    Pillow (a fork of the PIL library) provides Django-friendly image processing, crucial if your application handles uploaded photos or generates thumbnails. Whether you need to resize user uploads, validate image types, or do custom transformations, Pillow is the go-to library.

  8. Local Flavor: Handling Region-Specific Fields
    Django-Localflavor offers prebuilt validation rules, state/province lists, postal codes, and other region-specific data formats. Instead of manually coding all those form fields, you can quickly bring in correct address validation for countries around the world.

  9. Import-Export for Admin
    django-import-export seamlessly adds CSV/Excel/JSON import and export capabilities to the Django Admin. Teams can bulk-update objects or bring in new ones without directly touching the database. Admin users can also preview changes before they are applied, reducing risk of accidents.

  10. User Authentication with Django Allauth
    Django Allauth centralizes signup and login workflows, including email verifications, password resets, and connecting social logins (Facebook, GitHub, Google, etc.). It builds on Django’s native user model, letting you easily add OAuth-based authentication or unify multiple social providers for the same user account.

  1. Django Extensions and Django All
    Django Extensions is a broad suite of helpful commands (like show_urls, runscript) and model utilities that can supercharge your development. Django All (by guest Christopher Trudeau) bundles a handful of Django-isms—mixin classes, form utilities, ranking logic—for tasks he found himself repeating across projects.

Interesting Quotes and Stories

  • Christopher’s First Code: Christopher shared a nostalgic story of how his earliest coding endeavor on an IBM PC Junior involved drawing a Batman logo in BASIC. It was a pivotal moment that got him “hooked” on software.
  • Discovering Python: Christopher recounted how downtime at his job (post-acquisition) gave him the chance to dive into Python, and he never looked back, praising its minimal code requirements and vast library support.

Key Definitions and Terms

  • ORM (Object-Relational Mapping): A technique where Python objects map to rows in a database, letting you write Python instead of raw SQL.
  • Linting: Automated code checks for common bugs, style violations, and possible errors.
  • Async/await: Python keywords for writing asynchronous (non-blocking) code, often used in web frameworks like FastAPI or Django 3.2+ for concurrency.

Learning Resources

If you want to deepen your Python knowledge or learn Django from the ground up, check out these courses from Talk Python Training.

Overall Takeaway

From libraries that streamline testing and API development to those that transform the admin site into a powerful, user-friendly experience, Django’s ecosystem has everything you need to build full-featured web apps quickly. As Christopher Trudeau’s story shows, combining Python’s readability with Django’s batteries-included approach allows developers to focus on real business logic instead of reinventing basic web and data functionality. By learning how to pick and choose these libraries wisely, you can write less code while delivering richer, more reliable web applications.

Links from the show

Chris on Twitter: @cltrudeau
Django: Getting Started Course (by Chris): training.talkpython.fm

Foundational libraries:
coverage: coverage.readthedocs.io
Sphinx: sphinx-doc.org
Sphinx-rtd-theme: github.com
pudb: documen.tician.de
tox: tox.wiki
Pillow (sort of Django, needed by ImageField): github.com

Django libraries:
Django Ninja: django-ninja.rest-framework.com
DRF: django-rest-framework.org
Grappelli: github.com
django-import-export: github.com
Django Debug Toolbar: github.com
Django local flavor: github.com
Django admin-extra-buttons: github.com
django-awl: github.com
django-airplane: github.com
Django Extensions: github.com
django-allauth: github.com
awesome-django: github.com

‘Unstoppable’ Python: infoworld.com
asciimatics: github.com
Watch this episode on YouTube: youtube.com
Episode transcripts: talkpython.fm

--- Stay in touch with us ---
Subscribe to Talk Python on YouTube: youtube.com
Talk Python on Bluesky: @talkpython.fm at bsky.app
Talk Python on Mastodon: talkpython
Michael on Bluesky: @mkennedy.codes at bsky.app
Michael on Mastodon: mkennedy

Talk Python's Mastodon Michael Kennedy's Mastodon