Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Installing GeoDjango with PostgreSQL and zc.buildout
I've been wanting to play with GeoDjango for a while, since my database of choice (PostgreSQL) has excellent spatial support. However, getting all the dependencies up and running is pretty complicated. I've been working on a buildout to get at least most of the steps done for you. There are a couple of manual steps at the end, which I hope to automate when I next have time to work on this. The buildout installs the following items: PostgreSQL PostGIS GDAL Proj GEOS psycopg2 Django It should also perform initial setup of the PostGIS database template, loading some sample SQL files, and sets up some convenience symlinks for the PostgreSQL command-line programs. It's not finished - in particular, it just assumes that the user running the buildout is to be used as the database owner and such like. Anyway, here it is: [buildout]parts = postgresql postgis gdal init-pgsql pgsql-symlinks django eggs = psycopg2[postgresql]recipe = zc.recipe.cmmiurl = http://wwwmaster.postgresql.org/redir/198/h/source/v8.3.7/postgresql-8.3.7.tar.gzextra_options = --with-readline --enable-thread-safety [postgis]recipe = hexagonit.recipe.cmmiurl = http://postgis.refractions.net/download/postgis-1.3.5.tar.gzconfigure-options = --with-pgsql=${postgresql:location}/bin/pg_config --with-geos=${geos:location}/bin/geos-config --with-proj=${proj:location}[proj]recipe = zc.recipe.cmmiurl = http://download.osgeo.org/proj/proj-4.6.1.tar.gz[geos]recipe = zc.recipe.cmmiurl = http://download.osgeo.org/geos/geos-3.0.3.tar.bz2[gdal]recipe = zc.recipe.cmmiurl = http://download.osgeo.org/gdal/gdal-1.6.0.tar.gzextra_options = --with-python --with-geos=${geos:location}/bin/geos-config[init-pgsql]recipe = iw.recipe.cmdon_install = trueon_update = falsecmds = ${postgresql:location}/bin/initdb -D ${postgresql:location}/var/data -E UNICODE ${postgresql:location}/bin/pg_ctl -D ${postgresql:location}/var/data … -
Ajax Validation Aministrivia
Small administrative note, now that Github has it's own issue tracker users wishing to report issues with django-ajax-validation can now do so on Github, instead of the old Google Code page. Django-filter users can also report issues on its Github page, in place of the former system of "message or email me", which, though functional, wasn't very convenient. -
Developing Django apps with zc.buildout
Developing a Django app with zc.buildout Over the weekend I put together django-shorturls, the latest in a series of small plugable Django apps I’ve written. This time, though, I used zc.buildout and djangorecipe to build, test, package, and distribute the app, and (with the exception of a few annoyances) it’s an exceedingly civilized way to develop an app. In the interest of helping improve Buildout’s still-nascent documentation, I documented my steps along the way. -
How to make the Django 500 (server error) view useful
Django is pretty awesome. It comes with a lot of view functions built-in. One of these functions is the 500 (server error) view. Quoting the Django documentation for the 500 view: Django executes special-case behavior in the case of runtime errors in view code. If a view results in an exception, Django will, by default, call [...] -
Nobody expects Python packaging!
Python has one package distribution system: source files and setup.py install. And easy_install. Python has two package distribution systems: setup.py install and easy_install. And zc.buildout. Python has three package distribution systems: setup.py install, easy_install, and zc.buildout. And pip. Amongst Python’s package distribution are such diverse elements as… -
Sum for the range of a column in Excel
Working on my current project, one requirement came out which made me all the more appreciative of django's nice array of built-in filters. I generated an Excel report for my clients which is generated from html. Good and nice. Then one of them said, hey can the Excel report have a row which outputs the sum of the whole column of say the column E? Something usual and easy in Excel but stumped me for a while of how to do it from html to excel. For the most part it was trying to figure out how to include that SUM formula at my html code. A little visit to M$ support center got me the help I needed and then it was back to nice plethora of filters django has .... Turns out that you can include formula into a cell (or a table column in this case) by simply doing something like this '=SUM(E2:E70)' just after the opening tags for your column. This part actually took the longest for me as I did not really know how to do it correctly. My last row in this case was dynamic because it depended on the number of rows generated … -
Turning off django signals
While I'm on the subject, how to turn off signals that you don't want on. -
web.py, Dreamhost, and the django templating framework
Getting web.py working properly on Dreamhost was a real pain, especially since the wiki article on the subject was flat out wrong in several places. I ended up choosing to use fcgi for talking to apache, which is good for performance but not optimal for development work (you sometimes have to kill the process and [...] -
Dallas Django 1.1 Sprint
Djangonauts of Dallas rejoice! We are joining forces to have our very first Django Sprint event for the upcoming 1.1 release. For more info: When: Saturday, April 18, 2009 at 9:00am to Sunday, April 19, 2009 at 5:00pm Where: Cohabitat 2517 Thomas Ave. Dallas, TX Facebook Event Page: http://www.facebook.com/event.php?eid=81320026376&ref=nf -
Hooray for standards
Hey, look, it’s a new W3C site. Hm: <?xml version="1.0" encoding="utf-8"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> Ooh, XHTML… $ curl -sI http://beta.w3.org/ | grep 'Content-Type' Content-Type: text/html; charset=utf-8 Heh. -
Easier Translations with django-rosetta
I just found out about this Django application called django-rosetta that uses the Google AJAX Language API to suggest translations for translatable strings in your project. Even more interesting is the admin-like interface it creates to enter translations directly from a browser - and it doesn’t need any database tables, everything is directly written to translation files. I didn’t try it out yet, but if it works as advertised, it could become one of my default applications. Visit the bookmark » -
Building Better Web Services With Django (Part 1)
Building a RESTful webservice is pretty straight-forward with Django, but in many cases you want to have both a human readable website and a machine readable api. A lot of websites solve this problem by using www.x.com as the human site, an api.x.com as the machine site. They also will typically have different structures to [...] -
Django Site of the Week: The A.V. Club
It's been a while, but the Django Site of the Week is back. This week I spoke to Tom Tobin, developer at satire news site The Onion, about their Django-powered site The A.V. Club. Originally a Drupal website, Tom and his team converted the site to Django over a period odds three months. So how do they handle a million unique views a month? Read the article to find out. -
Django Site of the Week - The A.V. Club
For various reasons I haven't been able to post a Django Site of the Week for quite a while now, which is a little embarrassing. I've had this little interview sitting in my inbox for over a month, and I've only just been able to write it up and get it published. Just about everybody online has come across The Onion at some stage. Whether you have interpreted a satirical news story as the truth, or just read it for a laugh, The Onion is a staple of online publishing. A less-satirical yet still enjoyable feature of The Onion is The A.V. Club. Originally part of the printed Onion newspaper and then a PHP-powered Drupal based website, The A.V. Club is now running on Django - and the team who built it love Django to bits. This week, I spoke to Tom Tobin, web developer at The Onion. We discussed how they built the A.V. Club website, how they manage with a million unique visitors a month, and what their plans are for the future of The Onion's online presence. You can read the interview and leave your comments at the Django Site of the Week Website. -
Django Site of the Week - The A.V. Club
For various reasons I haven't been able to post a Django Site of the Week for quite a while now, which is a little embarrassing. I've had this little interview sitting in my inbox for over a month, and I've only just been able to write it up and get … -
Signal vs overriding save
I'm a big fan of signals and wonder why people are so adverse to using them, preferring overriding save instead. -
Django - autoryzacja przez Clickpass - tutorial
Clickpass umożliwia proste logowanie użytkowników za pomocą kont które już posiadają w innych systemach, np. hotmail, yahoo, google, facebook, aim, clickpass lub OpenID. Zasadę działania opisywałem w poprzednim poście. Teraz pokaże jak zaimplementować to w Django. Korzystam z aplikacji która ostatnio udostępniło washingtontimes, a mianowicie django-clickpass. Jest to aplikacja która bardzo upraszcza wykorzystanie clickpass w django. Instalacja Zainstaluj django-openid: svn co http://django-openid.googlecode.com/svn/trunk/django_openid django_openid Zainstaluj paczkę python OpenID 2.2.1 - http://openidenabled.com/files/python-openid/packages/python-openid-2.2.1.tar.gz. Szczegółowe instrukcje znajdziesz tutaj: http://www.openidenabled.com/python-openid/ Dodaj django_openid do Twoich INSTALLED_APPS. Zainstaluj django-clickpass: svn co http://opensource.washingtontimes.com/projects/public/django-clickpass/trunk/clickpass clickpass Dodaj clickpass do Twoich INSTALLED_APPS. Do głównych urls.py dodaj from clickpass.consumer import ClickPassConsumer Dodaj (r'^openid/(.*)', ClickPassConsumer()), do Twoich urlpatterns w urls.py: Przykład urls.py, do dodaniu ClickPassConsummer: from clickpass.consumer import ClickPassConsumer urlpatterns = patterns('', (r'^admin/(.*)', admin.site.root), (r'^moja_aplikacja/', include('moj_projekt.moja_aplikacja.urls')), (r'^openid/(.*)', ClickPassConsumer()), ) Dodaj clickpass.consumer.ClickPassConsumer do MIDDLEWARE_CLASSES gdzieś po django.contrib.sessions.middleware.SessionMiddleware, np: Przykład: MIDDLEWARE_CLASSES = ( 'django.middleware.common.CommonMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'clickpass.consumer.ClickPassConsumer', 'django_openid.consumer.SessionConsumer', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.middleware.doc.XViewMiddleware', ) W szablonach możesz dodać przycisk clickpass za pomoca template tag'a clickpass_button_large* lub clickpass_button_small. {% load clickpass %} {% if user.is_anonymous %} Zaloguj się {% clickpass_button_small %} {% else %} Zalogowano jako: {{user.first_name}} {{user.last_name}} {% endif %} Możesz także napisać kilka domyślnych szablonów które używa django-openid. Szablony są w katalogu: django_openid/templates/django_openid Konfiguracja konta clickpass Załóż tzw. … -
Django/Dojo Stammtisch in Berlin
For the second time Django enthusiasts are meeting in Berlin on Wednesday, the 15th April, 2009 at 19:30. Find all the details here. And since I will be in Berlin this time, I just simply redeclare this to “Django/Dojo Stammtisch” instead of just “Django Stammtisch” :-). I hope all the djangoers are ok with that (I requested permission in #django-de). It just makes things easier to also meet some dojo people in Berlin. I will also have some cool new dojango stuff to show off! So if AJAX, JavaScript and Dojo people are around, it would be cool to meet you there and chat about what’s hot and how the beer is. Please add yourself to the attendees list on doodle. And thanks again to the Berlin djangoers for organizing this, I am looking forward to it. -
The Django Deployment Survey - How Are You Hosting Django Websites?
According to the official Django Documentation, there are around a half-dozen documented and supported ways of deploying Django in production environments. The recommended way these days is with Apache and mod_wsgi, but there are still a whole bunch of decisions that one must make when it comes to making their Django project public. One of the great things about running DjangoSites is that it has exposed me to a number of fantastic Django-powered websites. Each of these is unique in one way or another, but they are all running Django. How they use it, though, is anybodies guess. So what are our peers doing? There are proponents for and against each of the different pieces of the Django Deployment puzzle. What operating system should be used? BSD, Linux or Windows? What Database system should be used? Postgres, MySQL, or something else? Which web server software? Apache, nginx, or one of the many python-powered web servers? Which method should I use? mod_python, FastCGI, or something else? Which version of Django? Do I stick to a release, or try and keep up with SVN? To see what our Django-using peers are doing, I am starting a survey of Django website deployment methods. … -
The Django Deployment Survey - How Are You Hosting Django Websites?
According to the official Django Documentation, there are around a half-dozen documented and supported ways of deploying Django in production environments. The recommended way these days is with Apache and mod_wsgi, but there are still a whole bunch of decisions that one must make when it comes to making their … -
A Django deployment guide for Ubuntu
There's a time when every Django developer has to think about deployment scenarios, when I first did it last year I thought that a setup involving Lighty, Apache, mod_proxy and mod_python was a good choice but my first approach was not the best. I put Apache as the front server, handling requests for Django generated pages and passing, via mod_proxy, requests for static content to Lighty on the back. A setup where Apache had to work even for files that wasn't supposed to serve was a very bad idea. After many helpful comments and some more reading I realized that it was better having the server for static content on the front and Apache, which still talks to Django, on the back. I replaced Lighty with nginx, which according to many seems to be more stable, and opted for mod_wsgi instead of mod_python to make Apache talk to Django. mod_wsgi has a lower memory overhead and it's suitable for high performance sites. There's no need for mod_proxy on Apache anymore as nginx is the one in charge of the proxy work now. This is an easy to follow and very focused guide for developers who know how to handle their … -
A Django deployment guide for Ubuntu
January 2012 update: I use and recommend gunicorn and Nginx for Django projects now. There's a time when every Django developer has to think about deployment scenarios, when I first did it last year I thought that a setup involving Lighty, Apache, mod_proxy and mod_python was a good choice but my first approach was not the best. I put Apache as the front server, handling requests for Django generated pages and passing, via mod_proxy, requests for static content to Lighty on the back. A setup where Apache had to work even for files that wasn't supposed to serve was a very bad idea. After many helpful comments and some more reading I realized that it was better having the server for static content on the front and Apache, which still talks to Django, on the back. I replaced Lighty with nginx, which according to many seems to be more stable, and opted for mod_wsgi instead of mod_python to make Apache talk to Django. mod_wsgi has a lower memory overhead and it's suitable for high performance sites. There's no need for mod_proxy on Apache anymore as nginx is the one in charge of the proxy work now. This is an easy … -
Django like templates in Javascript
Here's a quick ‘n’ dirty Javascript function I hacked together that provides Django-like template substitution. function sformat(template, data) { return template.replace(/{{(.*?)}}/g, function(m, n) { return eval('data.'+n); }); } Used something like this: sformat("Hello, {{ name }}!", {name:"World"}); Which returns the following string: Hello, World! Alas, it doesn't support anything other than substitution. If you need anything more advanced (loops etc), you should investigate Javascript template engines. -
Django like templates in Javascript
Here's a quick ‘n’ dirty Javascript function I hacked together that provides Django-like template substitution. function sformat(template, data) { return template.replace(/{{(.*?)}}/g, function(m, n) { return eval('data.'+n); }); } Used something like this: sformat("Hello, {{ name }}!", {name:"World"}); Which returns the following string: Hello, World! Alas, it doesn't support anything other than substitution. If you need anything more advanced (loops etc), you should investigate Javascript template engines. -
Django like templates in Javascript
Here's a quick ‘n’ dirty Javascript function I hacked together that provides Django-like template substitution. function sformat(template, data) { return template.replace(/{{(.*?)}}/g, function(m, n) { return eval('data.'+n); }); } Used something like this: sformat("Hello, {{ name }}!", {name:"World"}); Which returns the following string: Hello, World! Alas, it doesn't support anything other than substitution. If you need anything more advanced (loops etc), you should investigate Javascript template engines.