James Bennett
b-list.org · Personal blog · on HN since 2007
James Bennett, a longtime Django contributor, writes about Django, Python, web standards, and programming practice.
What HN saysHN commenters recommend his posts against service layers in Django, on request processing, and on the meaning of magic in frameworks.
95HN people shared it
28linked it in comments
100stories submitted
3.1Kstory points
3 months agolast shared
2007people per year2026
Most-shared posts
- 1Let's Talk about LLMs6 people · 10 points · first shared 2026 · discussion on HN
- 2Against Service Layers in Django6 people · 3 points · first shared 2020 · 3 comments on HN
- 3Boring Python: dependency management (2022)5 people · 117 points · first shared 2022 · 82 comments on HN
- 4Let's talk about WSGI4 people · 49 points · first shared 2009 · 5 comments on HN
- 5Variations on the Death of Python 24 people · 8 points · first shared 2020 · discussion on HN
- 6Let’s talk about usernames3 people · 903 points · first shared 2018 · 429 comments on HN
- 7How Python does Unicode3 people · 168 points · first shared 2017 · 136 comments on HN
- 8Truths programmers should know about case (2018)3 people · 88 points · first shared 2018 · 25 comments on HN
- 9On Python packaging3 people · 50 points · first shared 2008 · 7 comments on HN
- 10Good tools3 people · 11 points · first shared 2013 · discussion on HN
- 11Django, Accelerated3 people · 1 points · first shared 2007 · discussion on HN
- 12Reddit takes a new direction2 people · 392 points · first shared 2012 · 250 comments on HN
- 13On "magic", once again (from James Bennet, Django dev)2 people · 83 points · first shared 2009 · 14 comments on HN
- 14Minimal2 people · 25 points · first shared 2008 · 7 comments on HN
- 15Bullets of Vaguely Silvery Hue2 people · 4 points · first shared 2023 · discussion on HN
What HN people wrote when they linked it
gmt2027 · 2023-06-11
There's an argument against service layers in Django. The recommendation is to use instance and manager methods.
https://www.b-list.org/weblog/2020/mar/16/no-service/
karolsputo · 2021-12-07
I recommend this post when thinking about fat models/service layers
https://www.b-list.org/weblog/2020/mar/16/no-service/
cdubzzz · 2018-03-21
I don’t think GP was offering a comparison so much as a related item to check out.
Why would you not recommend code that checks the hashed password against a local DB?
See also the “pwned-passwords-django” process here: https://www.b-list.org/weblog/2018/mar/06/two-new-projects
dguaraglia · 2012-12-12
Yes, I know. It took me a long time to understand Django the way I do today. A great starting point was James Bennett's 'How Django processes a request' blogpost [1]. From there you'll see how Django is just a tiny wrapper calling a bunch of increasingly complex applications that build on top of each other.
There should probably be a chapter on the tutorial with a simplified version of that. It'd help newcomers understand where everything fits.
In any case, I'm glad you found a tool that does what you need as long as it isn't written in PHP :P
[1] http://www.b-list.org/weblog/2006/jun/13/how-django-processes-request/
xiongchiamiov · 2010-09-13
I think James Bennett's post on magic is interesting: http://www.b-list.org/weblog/2009/jul/23/magic/
In particular, there is a comment[0] that I think is particularly worth reading:
There are two different definitions of magic in play here.
1. The use of advanced language features in a manner that might be confusing to a novice programmer.
2. The use of ANY language feature to automate some process that a programmer would not expect to be automated.
I am of the belief that the second is the proper definition, which is something that is not usually solved by reading sourcecode, as the question is "Why?", rather than "What?" or "How?".
[0]: http://www.b-list.org/weblog/2009/jul/23/magic/#c118751
jacobian · 2009-03-28
Credit where credit is due: half of this tutorial is by James Bennett (http://b-list.org/).
brandonkm · 2008-06-03
I really like http://www.b-list.org for python/django related reads.
daniel_grady · 2024-02-16
Those are interesting pointers; appreciate it! My own experience over the past three years has been similar. I tried using Pipenv, and then Poetry, for internal projects at my company; in both cases the tool seemed overly complicated for the problem, slow, and I had a hard time getting co-workers on board. About a year and a half ago, I saw [Boring Python: dependency management](https://www.b-list.org/weblog/2022/may/13/boring-python-dependencies/)… which recommends using the third-party `pip-tools` library alongside the standard library’s `pip` and `venv`, and switched to that for the next project. It’s been working great. The project has involved a small team of scientists (four or five, depending) who use a mix of macOS and Windows. We do analysis and development locally and write production-facing algorithms in Python packages tracked in our repository, and publish releases to Gitlab’s PyPI. For our team, the “get up and running” instructions are “clone, create a venv, and pip install -r requirements.txt” and for the software team that manages the production systems, deploying an update just means pip installing a new version of the package. Every team’s got different constraints, of course, but this has been working very smoothly for us for over a year now, and it’s been easy, no pushback, with everyone understanding what’s going on. Really impressed with the progress of the core Python packaging infrastructure over the past several years.
hbrn · 2023-01-11
Ah, the typical "where to put business logic in Django".
M in ActiveRecord MVC web frameworks is deeply misunderstood. M is not "data model" (it would be called DVC if that was the case). M is your domain model. It's the model of your business, model of the real world. It's the core of your application.
Another thing that I never understood, why are functions called services? Is it a subconscious desire to go back to enterprisey kingdom of nouns? (apparently it is [1])
A service is either something that lives on a network (e.g. database, payment gateway, microservice). Or a class that has a state. Your functions are neither of those, they are just functions.
You business logic should live in the "models" namespace. Whether you put it on Model classes, or onto custom Managers, or just dump them into the module is not important, as long as you keep it consistent and keep your apps fairly small and isolated from each other.
Django already gives you enough tools to support big "enterprise" applications. It is far from perfect, but you'll get much further if you embrace the framework instead of fighting it.
If you really are attached to this "services" mindset then Django API Domains [2] is your best option.
[1] https://www.b-list.org/weblog/2020/mar/16/no-service/
[2] https://github.com/phalt/django-api-domains
jonatron · 2024-11-02
I think SQLAlchemy vs Django ORM was a 2007 blogging topic: https://www.b-list.org/weblog/2007/sep/04/orm-wars/
mdaniel · 2023-05-08
While trying to dig up more context, I found https://www.b-list.org/weblog/2012/feb/13/reddit/ which linked to https://web.archive.org/web/20131231120008/http://www.shirky.com/writi… (A Group Is Its Own Worst Enemy)
Navigating upward to the class syllabus also shows more of what's going on with the link itself: https://www.cc.gatech.edu/classes/AY2001/cs6470_fall/ (The Design of Online Communities by Amy Bruckman). [I think I took a video game course from her, but I'd have to dig out my transcript to say for sure]
simonw · 2022-12-20
"Boring Python" is the title of the series of posts, which started here: https://www.b-list.org/weblog/2022/may/13/boring-python-dependencies/
> This is the first in hopefully a series of posts I intend to write about how to build/manage/deploy/etc. Python applications in as boring a way as possible.
It's a riff on Boring Technology, see https://boringtechnology.club/
dd82 · 2021-06-23
James Bennet is of the same opinion as you re service layers
https://www.b-list.org/weblog/2020/mar/16/no-service/
https://www.b-list.org/weblog/2020/mar/23/still-no-service/
michaelmrose · 2020-11-16
This seems reasonable if you are considering only English speakers sharing files with other English speakers.
https://www.b-list.org/weblog/2018/nov/26/case/
Ndymium · 2018-05-16
That would require an array of 32 bit integers (basically UTF-32). It wastes a lot of space for most characters and doesn't help that much with indexing since user perceived characters can still be composed of many codepoints. Different languages take different approaches.
Python 3.3+, I believe, looks at the string and chooses ASCII/UCS-2/UCS-4 based on the character that takes the highest amount of bytes [1]. Elixir uses UTF-8 for strings (but you can get the codepoints easily), whereas Erlang uses the list of unicode ints style.
[1] https://www.b-list.org/weblog/2017/sep/05/how-python-does-unicode/
rdslw · 2018-02-13
This is very good primer on the topic, including unicode normalization, punycode and others, with ultra short python examples and links to more info.
https://www.b-list.org/weblog/2018/feb/11/usernames/
ubernostrum · 2017-09-18
Mozilla is not funded by Google anymore, and hasn't been for several years (the Google contract ended back when I was still working at Mozilla).
If you're interested, I wrote up some notes/thoughts from my experience in one of the sessions about EME and whether to implement it:
http://www.b-list.org/weblog/2013/oct/16/eme/
kmfrk · 2014-02-16
James stopped work on django-registration half a year ago: http://www.b-list.org/weblog/2013/aug/26/catching/.
Maybe people who still hold a grudge over a year later should get off their asses and take some responsibility for the fork instead? If James is so awful, and django-registration needs to be updated so badly, then why aren't we hearing about the armies of people who've taken up James's offer to take over django-registration?
adambyrtek · 2012-06-22
Another post on the same subject written a few years ago: http://www.b-list.org/weblog/2008/dec/14/packaging/
draegtun · 2012-02-09
>> All frameworks (ish) play nicely with Plack, which is a straight rip-off of Rack
When developing PSGI/Plack, Miyagawa not only looked at Rack but also WSGI (Python) and also the proposed improvements to WSGI.
ref: http://bulknews.typepad.com/blog/2009/09/psgi-perl-wsgi.html | http://www.b-list.org/weblog/2009/aug/10/wsgi/ | http://jacobian.org/writing/snakes-on-the-web/
ak217 · 2011-12-26
In addition to this, I recently discovered that Flask doesn't support Transfer-Encoding: chunked (which is part of the HTTP/1.1 spec), and doesn't fail gracefully either (when receiving a chunked request). Then I discussed it with Armin and realized that the WSGI spec prevents Flask from doing either. (See also http://www.b-list.org/weblog/2009/aug/10/wsgi/)
Time to fork WSGI?
ETA: Upon further investigation, there's a big discussion out there on what to replace WSGI with, here's one entry point: http://dirtsimple.org/2011/08/is-wsgi-lite-library-or-protocol-and.htm…
MWinther · 2010-05-15
When it comes to authentication, wouldn't it be rather easy to subclass the ModelBackend class to simply use email instead of username if that's what you want? And if you want to extend user.Auth with more user data, they have a way of doing so as well, without subclassing: http://www.b-list.org/weblog/2006/jun/06/django-tips-extending-user-mo…
Could you be more specific as to what kind of things the Symfony/Doctrine model level validation can do?
arthurk · 2009-11-26
"Why not create a ‘templates’ directoy and a ‘base.html’ either in project’s directory or in the apps’s directory, because creating the same templates directory and same base.html for every project is not DRY?"
There's nothing wrong with that. Even the djangoproject.com website does it: http://code.djangoproject.com/browser/djangoproject.com/django_website
"Why serving static files in development has to be a additional setup, as no developer wants to setup a server for serving static files, I am aware of ‘django.static.serve’ but still that is an additional setup, why not create a sample media directory and a url for the same in urls.py ?"
Read this: http://www.b-list.org/weblog/2008/jun/23/media/
tdavis · 2008-12-15
Also discussed here: http://www.b-list.org/weblog/2008/dec/14/packaging/
On HN: http://news.ycombinator.com/item?id=397426
dood · 2007-09-05
Adam Gomaa suggests writing your own mapper around SQLAlchemy. Django [http://www.b-list.org/weblog/2007/sep/04/orm-wars/] and Pylons [http://groovie.org/articles/2007/09/04/sqlalchemy-declarative-layers-a… devs share their thoughts.
[seems to be a bug, I tried to add this as 'text' for the submission, but it didn't show up]
simoncion · 2026-04-17
> All articles are mostly a regurgitation of all the negativity that gets aired here all the time (a lot of it already fixed or debunked) and 0 discussion of utility.
There are multiple sections that talk directly about utility. Here's one of them: [0]
But, sure. I'll bite. Here's the third paragraph of the first part of the essay [1]:
This is *bullshit* about *bullshit machines*, and I mean it. It is neither balanced nor complete: others have covered ecological and intellectual property issues better than I could, and there is no shortage of boosterism online. Instead, I am trying to fill in the negative spaces in the discourse. “AI” is also a fractal territory; there are many places where I flatten complex stories in service of pithy polemic. I am not trying to make nuanced, accurate predictions, but to trace the potential risks and benefits at play.
I'd say that the specific sort of "utility" discussion that you're probably looking for would be classified as "boosterism". [2]
> Now it can scale with power and compute.
Eh. Carefully read through and consider [3].
[0] <https://aphyr.com/posts/411-the-future-of-everything-is-lies-i-guess#m…
[1] <https://aphyr.com/posts/411-the-future-of-everything-is-lies-i-guess&g…
[2] Due to their nearly-universally breathless nature, I know that's how I classify the overwhelming majority of such discussions.
[3] <https://www.b-list.org/weblog/2026/apr/09/llms/>
omfut · 2008-05-07
That’s a hard spot to be in. I can hear your pain on how you want you idea to be launched. Honestly, learning django is no brainer. Django guys have done an amazing job building the framework. On a side note, why is your prototype taking that long? In today’s world, you can build complex apps faster than you can think off.
Here is some links that can be handy for your django learning. All the best!
This is a excellent wiki with lot of tutorial/information/samples about django
http://code.djangoproject.com/wiki/Tutorials
http://www.b-list.org/weblog/2006/nov/16/django-tips-get-mos...
http://www.b-list.org/weblog/2007/sep/04/django-accelerated/
http://www.slideshare.net/simon/advanced-django/
http://djangoplugables.com/
http://www.djangoproject.com/community/
http://djangobook.com
http://showmedo.com/videos/video?name=1100000&fromSeries... http://showmedo.com/videos/series?name=v7kABKL6R http://blog.disqus.net/2007/03/11/a-django-primer/
http://www-128.ibm.com/developerworks/linux/library/l-django...
kyro · 2008-04-28
http://code.djangoproject.com/wiki/Tutorials
and
http://www.b-list.org/weblog/2006/nov/16/django-tips-get-most-out-gene…
http://www.b-list.org/weblog/2007/sep/04/django-accelerated/
http://www.slideshare.net/simon/advanced-django/
http://djangoplugables.com/
Those are some sites I've come across when I was, and still am, learning Django. Good luck.