Simon Willison’s Weblog

Subscribe

Items tagged django, python

Filters: django × python × Sorted by date


Talking about Django’s history and future on Django Chat (via) Django co-creator Jacob Kaplan-Moss sat down with the Django Chat podcast team to talk about Django’s history, his recent return to the Django Software Foundation board and what he hopes to achieve there.

Here’s his post about it, where he used Whisper and Claude to extract some of his own highlights from the conversation. # 21st March 2024, 12:42 am

DiskCache (via) Grant Jenks built DiskCache as an alternative caching backend for Django (also usable without Django), using a SQLite database on disk. The performance numbers are impressive—it even beats memcached in microbenchmarks, due to avoiding the need to access the network.

The source code (particularly in core.py) is a great case-study in SQLite performance optimization, after five years of iteration on making it all run as fast as possible. # 19th March 2024, 3:43 pm

Building Search DSLs with Django (via) Neat tutorial by Dan Lamanna: how to build a GitHub-style search feature—supporting modifiers like “is:open author:danlamanna”—using PyParsing and the Django ORM. # 19th June 2023, 8:30 am

djngo.com: Portable Django (via) “A 20mb executable zip file with Python 3.6 and Django 2.2. Works on Windows, Linux, MacOSX with x86_64 and aarch64 (yes, Apple M1 and Raspberry Pi).” The latest wizardry from the ecosystem surrounding the Cosmopolitan project, which provides a should-be-impossible mechanism for running the same executable on a bunch of different platforms. This utility by Ariel Núñez bundles Python and Django and SQLite, such that a Django application can become a portable executable ready to run on multiple platforms. It’s currently limited to Python 3.6 and Django 2.2 since those are the versions that run under Cosmopolitan, but I expect we’ll see more recent versions of those dependencies in the future. # 24th February 2023, 12:52 am

Black 22.1.0 (via) Black, the uncompromising code formatter for Python, has had its first stable non-beta release after almost four years of releases. I adopted Black a few years ago for all of my projects and I wouldn’t release Python code without it now—the productivity boost I get from not spending even a second thinking about code formatting and indentation is huge.

I know Django has been holding off on adopting it until a stable release was announced, so hopefully that will happen soon. # 30th January 2022, 1:23 am

django-upgrade (via) Adam Johnson’s new CLI tool for upgrading Django projects by automatically applying changes to counter deprecations made in different versions of the framework. Uses the Python standard library tokenize module which gives it really quick performance in parsing and rewriting Python code. Exciting to see this kind of codemod approach becoming more common in Python world—JavaScript developers use this kind of thing a lot. # 26th September 2021, 5:42 am

Inevitably we got round to talking about async.

As much of an unneeded complication as it is for so many day-to-day use-cases, it’s important for Python because, if and when you do need the high throughput handling of these io-bound use-cases, you don’t want to have to switch language.

The same for Django: most of what you’re doing has no need of async but you don’t want to have to change web framework just because you need a sprinkling of non-blocking IO.

Carlton Gibson # 27th September 2020, 3:09 pm

Pysa: An open source static analysis tool to detect and prevent security issues in Python code (via) Interesting new static analysis tool for auditing Python for security vulnerabilities—things like SQL injection and os.execute() calls. Built by Facebook and tested extensively on Instagram, a multi-million line Django application. # 7th August 2020, 8:50 pm

PEP 8016 -- The Steering Council Model (via) The votes are in and Python has a new governance model, partly inspired by the model used by the Django Software Foundation. A core elected council of five people (with a maximum of two employees from any individual company) will oversee the project. # 17th December 2018, 4:02 pm

Channels 2.0. Andrew just shipped Channels 2.0—a major rewrite and redesign of the Channels project he started back in 2014. Channels brings async to Django, providing a logical, standardized way of supporting things like WebSockets and asynchronous execution on top of a Django application. Previously it required you to run a separate Twisted server and redis/RabbitMQ queue, but thanks to Python 3 async everything can now be deployed as a single process. And the new ASGI spec means its turtles all the way down! Everything from URL routing to view functions to middleware can be composed together using the same ASGI interface. # 2nd February 2018, 6:19 pm

Using setup.py in Your (Django) Project. Includes this neat trick: if you list manage.py in the setup(scripts=) argument you can call it from e.g. cron using the full path to manage.py within your virtual environment and it will execute in the correct context without needing to explicitly activate the environment first. # 2nd February 2018, 12:33 pm

Building a statistical profiler in python. Generating flame graphs of production Python code is surprisingly straight-forward. Brian Pitts built a statistical flame graph profiler into our tikibar debugging tool at Eventbrite and it’s proved extremely useful. # 5th October 2017, 3:44 pm

Why is snapEDA.com slow? Is it because it uses Django?

No, it’s not slow because it uses Django.

[... 36 words]

What are some good resources to learn how to cleanse data using Python?

http://gnosis.cx/TPiP/ “Text Processing in Python” is a free online book that covers a bunch of useful topics related to data cleanup. It’s over 10 years old now but is still mostly relevant—the chapter on regular expressions is particularly good.

[... 61 words]

Is it better to create your own framework, or would it be best to just use Django or something like that?

You should absolutely use an existing framework such as Django rather than writing your own.

[... 176 words]

For a Django application, deployed on Heroku, what are my options for storing user-uploaded media files?

S3 is really a no-brainer for this, it’s extremely inexpensive, very easy to integrate with and unbelievably reliable. It’s so cheap that it will be practically free for testing purposes (expect to spend pennies a month on it).

[... 88 words]

What advice would Simon Willison give to a beginner Python/Django developer?

Build something and put it on the internet. Make sure you have an easy way to deploy new versions (Heroku is a good bet if you don’t want to figure out Fabric). Pick a project that’s useful to you—a simple blogging engine is often a good bet, or maybe something that aggregates together your posts from Twitter and Instagram and so on. Or come up with something a bit more creative!

[... 109 words]

What is the best way to deploy Django?

These days a popular and reliable method is to run gunicorn behind nginx. This tutorial includes notes on using upstart for process management which is handy if you are on Ubuntu: http://lincolnloop.com/django-be...

[... 47 words]

Do Flask and Django have a GUI interface like web2py?

No. The web2py GUI is something of an oddity in the Python world.

[... 65 words]

What are some apps, problems you would suggest to solve a new python developer?

The best way to learn python in my opinion is using the interactive prompt. Install ipython (a massive improvement on the standard python shell) and use it to interactively solve some simple tasks—things like downloading a CSV file from the web using the urllib library, parsing it with the csv module, then poking around in the data using python list comprehensions and saving some of the results out to a JSON file.

[... 95 words]

What web programming framework best supports ’drag and drop’ actions?  Please give examples of sites and/or plug-ins that support the interaction.

Drag and drop is a client-side thing—it has nothing to do with the server-side technology being used.

[... 72 words]

Python Django load MySQL database from csv files performance issue?

Don’t use the Django ORM for bulk imports—the performance overhead is pretty small for regular web page stuff, but it adds up if you are running millions of inserts.

[... 63 words]

How can I look up Django functions?

You can use the ./manage.py shell command to get a shell which will import any Django modules (or any of your own code) without complaining about the location of the settings.py module. Install IPython first to get a much more useful interactive shell when you run that command.

[... 190 words]

How can I install Django in a server without shell access?

I don’t think you can.

[... 42 words]

Do Python programmers have a tendency to write their own software instead of contributing? Why?

I think you’ll find that PROGRAMMERS have a tendency to develop their own thing rather than contributing to an existing project. It’s even got its own TLA: NIH (Not Invented Here).

[... 94 words]

Are there any good Django video tutorials?

ShowMeDo has 55 video screencasts covering all sorts of aspects of Django development: http://showmedo.com/videotutoria...

[... 56 words]

Is Django on its way out?

Not as far as I can tell—but then like many (most?) other Django users I’m too busy using it to build things to worry too much about whether or not it’s fashionable.

[... 46 words]

Is South the best tool to use when doing database migrations in Django?

Yes. And I say that as an author of another Django migrations tool (dmigrations) which offered a small subset of South’s current functionality.

[... 42 words]

The First Few Weeks—ep.io. Another take on managed Python Django/WSGI hosting, from Andrew Godwin and Ben Firshman. # 13th January 2011, 4:25 am

What are the tradeoffs (e.g. development speed, performance, scalability) between using various php frameworks, ruby/rails, or python/django?  Is there any reason to choose one overwhelmingly over another?

At this point, I’d argue that the decision between them comes down to programming language rather than framework—the frameworks have mostly converged on a very similar set of features.

[... 145 words]