Simon Willison’s Weblog

Subscribe
Atom feed for django

565 items tagged “django”

The Django web framework.

2017

pythondotorg/admin.py (via) There are some neat tricks in the Django application that powers Python.org (built a few years ago by RevSys). Here’s how their admin app handles creator/last_modified_by user relationships.

# 19th November 2017, 6:28 am / django

DSF calls for applicants for a Django Fellow. This is a fantastic opportunity: the Django Software Foundation’s fellowship program is providing the opportunity for a new developer to get paid to work on Django 20-40 hours a week. Tim Graham has held this position full-time for the past three years and is looking to scale back to part-time, hence this new opportunity. Applications are due by December 18, 2017.

# 16th November 2017, 10:31 pm / django, dsf

django-multitenant (via) Absolutely fascinating Django library for horizontally sharding a database using a multi-tenant pattern, from the team at Citus. In this pattern every relevant table includes a “tenant_id”, and all queries should specifically select against that ID. Once you have that in place, you can shard your rows across multiple different databases and route to the correct database based on the tenant ID, safe in the knowledge that joins will still work provided they are against other rows belonging to the same tenant.

# 16th November 2017, 9:12 pm / scaling, postgresql, django

Using “import refs” to iteratively import data into Django

I’ve been writing a few scripts to backfill my blog with content I originally posted elsewhere. So far I’ve imported answers I posted on Quora (background), answers I posted on Ask MetaFilter and content I recovered from the Internet Archive.

[... 559 words]

Squeezing every drop of performance out of a Django app on Heroku. Ben Firshman describes some lesser known tricks for scaling Django on Heroku—in particular, using gunicorn gevent asynchronous workers and setting up PostgreSQL connection pooling using django-db-geventpool.

# 31st October 2017, 2:08 pm / postgresql, heroku, django

arxiv-vanity (via) Beautiful new project from Ben Firshman and Andreas Jansson: “Arxiv Vanity renders academic papers from Arxiv as responsive web pages so you don’t have to squint at a PDF”. It works by pulling the raw LaTeX source code from Arxiv and rendering it to HTML using a heavily customized Pandoc workflow. The real fun is in the architecture: it’s a Django app running on Heroku which fires up on-demand Hyper.sh Docker containers for each individual rendering job.

# 25th October 2017, 8:06 pm / docker, science, ben-firshman, django, pdf

A Brief Intro to Docker for Djangonauts (via) This is great—a really clear introduction to both Docker and Docker Compose, aimed at Django developers. Includes line-by-line annotations of an example Dockerfile and docker-compose.yml.

# 18th October 2017, 9:06 pm / docker, django

How to set up world-class continuous deployment using free hosted tools

I’m going to describe a way to put together a world-class continuous deployment infrastructure for your side-project without spending any money.

[... 1,294 words]

My essential django package list. Insightful list of Django packages—many of which I hadn’t seen before—by Serafeim Papastefanos, each with a handy explanation of what it’s useful for and why.

# 11th October 2017, 2:42 pm / django

Generate dynamic titles for /search/ pages. Fun little enhancement to my faceted search implementation: I now generate dynamic titles for each search results page describing the search, e.g. “Blogmarks tagged security in Feb, 2005” or ““python” in quotations tagged ruby, python in 2007”.

# 8th October 2017, 7:47 pm / facetedsearch, django

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 / profiling, tikibar, django, python

Implementing faceted search with Django and PostgreSQL

Visit Implementing faceted search with Django and PostgreSQL

I’ve added a faceted search engine to this blog, powered by PostgreSQL. It supports regular text search (proper search, not just SQL“like” queries), filter by tag, filter by date, filter by content type (entries vs blogmarks vs quotation) and any combination of the above. Some example searches:

[... 3,103 words]

Running gunicorn behind nginx on Heroku for buffering and logging

Heroku’s default setup for Django uses the gunicorn application server. Each Heroku dyno can only run a limited number of gunicorn workers, which means a limited number of requests can be served in parallel (around 4 per dyno is a good rule of thumb).

[... 400 words]

The denormalized query engine design pattern

Visit The denormalized query engine design pattern

I presented this talk at DjangoCon 2017 in Spokane, Washington. Below is the abstract, the slides and the YouTube video of the talk.

[... 356 words]

2016

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

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

[... 36 words]

2015

Are traditional web frameworks and languages like RubyOnRail, Spring Boot and PHP dying now when new fast reactive pure JavaScript frameworks and services like Meteor, Node, Angular 2.0 and Firebase are breaking ground?

No.

[... 40 words]

2014

Feature Flags, from PyCon 2014. Slides from a 15 minute talk I gave at PyCon 2014 about feature flags - what they are, how to use them and how we implemented them at both Lanyrd and Eventbrite.

This was part of a longer workshop on Advanced Django Patterns from Eventbrite and Lanyrd, which I co-presented with Andrew Godwin and Nathan Yergler.

# 10th April 2014, 6:27 pm / pycon, python, django, feature-flags, speaking

Should I use Django forms or pure HTML in order to do not establish borders for the growth of my app?

Use Django forms. Django scales horizontally on the front-end, so if your site needs to handle large amounts of traffic you just need to run multiple front-end servers—your form handling code will scale up just fine.

[... 65 words]

2013

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.

Are Django versions released too often?

The Django release process is well documented (see Django’s release process) and has been specifically designed to address the concerns of developers who don’t want to have to spend too much time keeping up to date with the latest version.

[... 182 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]

How can Google’s Zopfli compression algorithm be implemented in Django’s cache system?

It’s pretty easy to write custom backends for Django’s caching layer—check out https://github.com/sebleier/djan... for example.

[... 36 words]

Why is postgresql popular with django?

Partly because the first applications developed on Django (before it was even called Django) used PostgreSQL, so it’s had great PostgreSQL support baked in from the start.

[... 74 words]

How scalable is Django?

Django scales in exactly the same way as PHP or Rails or any other stateless shared-nothing web technology: you ensure that the web nodes (running your Django code) are independent from your persistence layer (database, caching, session storage etc) and scale then independently.

[... 191 words]

My boss wants me to choose drupal over django for website develpment.How can I convince him to choose django?

You could point him to Django (web framework): Why did theonion.com stop using Drupal?

[... 40 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]

2012

How can I detect manual record insert from mysql cansole into my code in django .?

You can’t. The best you can do is have Django periodically poll MySQL to see if anything has changed (maybe with a custom management command run by cron)—having a TIMESTAMP field on every table which will be automatically set to the current time when a record is inserted will help you spot things that have changed.

[... 80 words]