Simon Willison’s Weblog

Subscribe

Items tagged django in 2012

Filters: Year: 2012 × django × Sorted by date


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]