dj-notebook: the REPL I’ve Always Wanted for Django

This year, I’ve really started to like jupyter notebooks. I first tried them out several years ago, but they’ve only just started to click for me. They haven’t changed; the difference is how I think about them. When I initially tried them, they felt like writing untestable code in a browser, where you could get yourself into an unknowable state very easily as you navigated between cells. While they certainly can be that, it was an incomplete impression, at best.

One thing changed my mind this year: I learned about the --notebook option for django-extensions shell_plus management command. shell_plus is a command that gives you a REPL with all your django models and many of the framework’s utility classes imported and ready to go. The --notebook option has shell_plus import that all into a jupyter notebook that you can access from your browser. Or that you can save and access from your IDE’s notebook support. It’s like absolute magic when it works, but lately you have to hold your jaw just right and explicitly specify a few dependencies' versions in order to make it work. It was 15 minutes of internet searching every time I felt like I was going to spend enough time in my REPL to want it. I recently learned about dj-notebook, which fixes that and adds a few useful features on top of it.

Read more →

Hypermedia Systems - Using Django - More htmx patterns

I’m working through Hypermedia Sytstems using django and htmx in public. This post starts applying the patterns from Chapter 6: More Htmx Patterns.
Read more →

Hypermedia Systems - Using Django - Adding htmx (pt 2)

I’m working through Hypermedia Sytstems using django and htmx in public. This post continues to work through Chapter 5: HTMX Patterns.
Read more →

Hypermedia Systems - Using Django - Adding htmx (pt 1)

I’m working through Hypermedia Sytstems using django and htmx in public. This post picks up with Chapter 5: HTMX Patterns.
Read more →

Hypermedia Systems - Using Django - Contacts.app Web 1.0 edition

I’m working through Hypermedia Sytstems using django and htmx in public. This post covers building out the Web 1.0 edition of the book’s contacts app.
Read more →

Hypermedia Systems - Using Django (introduction)

I’m reading and enjoying Gross et al’s Hypermedia Sytstems. This post is the start of my plan to work through the exercises in public using Django and HTMX.
Read more →

Django, HTMX, and front-end scripting

As I’ve mentioned a few times, HTMX is really growing on me for building web things lately. When stacked on top of Django, it lets me mostly write server side code, which is my comfort zone, but get pages that load and behave the way people expect them to in 2022. It doesn’t free me from all need to write stuff that runs in the browser, though. Here’s what I’ve found useful lately.
Read more →

How I Start: Django, Tailwind, HTMX (part 5)

In part 4 of this series, we got forms in place to add and edit books in the library, then made them look better using django-crispy-forms. The many-to-many relationship between books and authors brought some weaknesses of the Crispy Tailwind theme to light, and it took a bit of effort to address that. Now it’s time to get deletion working before we make everything work a little better using HTMX.
Read more →

How I Start: Django, Tailwind, HTMX (part 4)

In part 1 and part 2, we got the basic project workflow set up. Part 3 saw some initial models and views that were tested using the Django admin UI. Now it’s time to add library CRUD to the reading_log application itself.
Read more →

Adding shell_plus for Django to PyCharm’s Python Console

I’m blogging this because I find myself looking it up repeatedly. Every time I start a project, I eventually hit a point where I use the REPL quite a bit. Usually I want to use it from PyCharm’s python console. And I usually find myself manually typing 5 or 6 commands at the start of each session that shell_plus from django-extensions would give me for free.
Read more →