Simon Willison’s Weblog

Subscribe

541 items tagged “django”

2013

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]

How much Django should one know before going in for an interview for a developer position?

I’ve hired people for Django positions who didn’t know Django at all. If you’re a good web engineer you should be able to pick up Django in a few days, and be properly productive with it in a few weeks. Instead, I’m interested in testing your understanding of the key underlying concepts: HTTP, SQL, HTML and JavaScript, XSS, CSRF, scaling, cookies, web app security in general, web performance optimisation, unit testing, refactoring, model/template/view-or-controller—and evidence that you’ve solved problems relating to those in production environments.

[... 177 words]

Django (web framework): What are the Best Practice For Displaying another Website from yours?

This isn’t really a Django-specific question—the answer would be the same no matter what server-side tech you use.

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

Django (web framework): What is the recommended way to cache objects that are very large (>1.5MB)?

Take a look at redis—it can handle binary strings up to 512 MB and has performance that is similar to memcache. It’s very easy to use from within Django (there’s even a pluggable cache backend for it).

[... 61 words]

How can I learn more about server-side technologies?

Get yourself a VPS, set it up from scratch and run some non-critical websites on it (nothing with private user data since you can’t be sure you’ll set it up securely). Both Slicehost and Linode offer a good set of guides to a whole host of common tasks:

[... 109 words]

How do you organize the code in your Django project?

For http://lanyrd.com/ our layout looks something like this:

[... 214 words]

Why doesn’t the Django framework come with its own REST API out of the box?

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.

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

Play Framework, Django or Rails? Which one do you recommend for  Social Networking Web applications.

Both Rails and Django have been used for a large number of high profile social networking web applications. Off the top of my head, Django is used by Instagram and Pinterest, Rails is used by Posterous and Ravelry. I don’t know what the largest sites built using Play are at the moment.

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

2011

Is there a way to find out what apps are used by a specific django-based website?

Not really. You might be able to figure out some of them by looking out for common patterns of URLs and form field names, but a lot of reusable django apps don’t really expose much of a signature.

[... 60 words]

What are you some good blogs, videos, papers, etc. on scaling Django?

We’re building up a pretty sizable collection of video (and slides) from talks about Django on http://lanyrd.com/—including plenty that talk about scaling issues. Try this: http://lanyrd.com/search/?q=djan...—we have 16 videos and 16 slide decks from talks at events all over the world.

[... 102 words]

Why does Django still not have support for multiple joins?

I don’t fully understand the question, but if you’re talking about doing a single join across multiple tables the Django ORM handles that just fine. Let’s say you want to get every BlogEntry written by a User who belongs to the Group with the name “admins”:

[... 67 words]

CSRF: Flash + 307 redirect = Game Over. Here’s the exploit that Django and Rails both just released fixes for. It’s actually a flaw in the Flash player. Flash isn’t meant to be able to make cross-domain HTTP requests with custom HTTP headers unless the crossdomain.xml file on the other domain allows them to, but it turns out a 307 redirect (like a 302, but allows POST data to be forwarded) confuses the Flash player in to not checking the crossdomain.xml on the host it is being redirect to. # 10th February 2011, 10:07 pm

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]

Which web server suits Django best? Apache, Nginx or something else?

I’m still a big fan of a stripped down Apache+mod_wsgi running behind nginx.

[... 98 words]

What is the best way to debug a Django app?

The Django Debug Toolbar is essential: http://robhudson.github.com/djan...

[... 95 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

Hello from Gondor. “Effortless production Django hosting” from the Eldarion team. # 13th January 2011, 4:24 am