Why doesn’t the Django framework come with its own REST API out of the box?
20th September 2012
My answer to Why doesn’t the Django framework come with its own REST API out of the box? on Quora
I’d argue that it does. If you want to build a REST API you need to be able to map incoming HTTP requests to handler functions based on their URL, run some custom code and return an HTTP response containing JSON (or maybe XML). Django makes all of this really simple.
Once you go beyond that basic set of functionality things get opinionated very quickly. There are some excellent libraries for Django that help you put together a RESTful oAuth-protected API quickly (https://github.com/toastdriven/d... for example)—but they have pretty strong opinions on how those APIs should be structured. That’s fine for a third party module, but it’s not necessarily the right thing to happen in the core framework.
Guido van Rossum once said of the Python Standard Library that once a module is added to it it already has one foot in the grave... this is very true: once something is part of Django (or Python) core development becomes MUCH more restricted... there are backwards compatibility guarantees to worry about, and a release cycle that’s much, much slower than for a standalone module.
So for something as opinionated and fast-moving as a REST API toolkit, its much better off as a third party module (like tastypie), free from the restrictions that come with being included in Django itself.
Incidentally, this logic is the main reason Django doesn’t yet ship with a built-in database migrations solution yet.
Another thing... once a solution is chosen to ship with Django, the incentive for other developers to try their own approach is reduced. Sometimes it’s better to let a bunch of solutions blossom and explore the space than to prematurely pick a “winner”.
These are just my opinions (and I’m certainly not an active Django contributor these days), but I expect you’d get a similar answer from Django’s current core developers.
More recent articles
- Weeknotes: Llama 3, AI for Data Journalism, llm-evals and datasette-secrets - 23rd April 2024
- Options for accessing Llama 3 from the terminal using LLM - 22nd April 2024
- AI for Data Journalism: demonstrating what we can do with this stuff right now - 17th April 2024
- Three major LLM releases in 24 hours (plus weeknotes) - 10th April 2024
- Building files-to-prompt entirely using Claude 3 Opus - 8th April 2024
- Running OCR against PDFs and images directly in your browser - 30th March 2024
- llm cmd undo last git commit - a new plugin for LLM - 26th March 2024
- Building and testing C extensions for SQLite with ChatGPT Code Interpreter - 23rd March 2024
- Claude and ChatGPT for ad-hoc sidequests - 22nd March 2024
- Weeknotes: the aftermath of NICAR - 16th March 2024