Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Django Facebook – Open graph API implementation
Update: This blog post is outdated, a new and vastly upgraded version of Django Facebook is now available. Read more about it here. For Fashiolista.com we needed to integrate with the Facebook Open Graph API. The open graph API is a very exciting facebook project, which you can read about more here and here. The code at fashiolista.com allows you to register/login via facebook using the Open Graph API (similar to the old Facebook connect, but registration, instead of only logging in). Before you go try it out, fashiolista.com is aimed primarily at females so your girl friends facebook account is probably a better fit. Im releasing the source code for Django Facebook on github. Its a very early release, but it might help other developers trying to implement a facebook register/loging flow using the new open graph api. See Github for requirements and installation instructions. Update: Birthday formats are currently giving some troubles for some users. Fixed and tests added to prevent future problems. (note Fashiolista.com may still give errors, will be resolved during our next release). Share and Enjoy: -
Index definition mystery
According to the App Engine documentation, the index definitions at index.yaml should be added automatically by the development web server. But, in my current project setup, it's not happening that way, and I have to manually make the entries for it, atleast for the admin application.Now sure whether this is a bug at App Engine, or Django-nonrel, or at my end. But would surely like to get to the bottom of this. And when I do, will get back with more info about it here. -
Index definition mystery
According to the App Engine documentation, the index definitions at index.yaml should be added automatically by the development web server. But, in my current project setup, it's not happening that way, and I have to manually make the entries for it, atleast for the admin application.Now sure whether this is a bug at App Engine, or Django-nonrel, or at my end. But would surely like to get to the bottom of this. And when I do, will get back with more info about it here. -
Cronograna de lançamento do Django 1.2 -- atualização final
Cronograna de lançamento do Django 1.2 -- atualização final -
Cronograna de lançamento do Django 1.2 -- atualização final
Cronograna de lançamento do Django 1.2 -- atualização final -
Ported to Django-nonrel
Working with the google-app-engine-django helper was proving to be of some pain. Not only did I have to write the code twice, it was also getting very hectic to test the application too! So, decided to look for alternatives. After searching through the list of alternative, which wasn't long anyway, I decided to try out Django-nonrel.After going through it's documentations and also trying out it out, finally decided to switch the from the "django-app-engine-django" helper to the "Django-nonrel" port.Although it doesn't yet support all of Django APIs out of the box, but still has support upto a certain acceptible extent. The best part seems to be the way in which the port is supposed to work. And being currently a very active project, it's future and prospect seems good. They're using the lastest version of Django and hacking it's core to get support for non-relational databases and the App Engine database backend.The manage.py looks loaded with many useful common features, other than just the regular ones. Now remote login python shell to the GAE application server is just too easy. Infact the remote feature can be used with it's other subcommands too.Overall, it seemed to be the most promising thing … -
Ported to Django-nonrel
Working with the google-app-engine-django helper was proving to be of some pain. Not only did I have to write the code twice, it was also getting very hectic to test the application too! So, decided to look for alternatives. After searching through the list of alternative, which wasn't long anyway, I decided to try out Django-nonrel.After going through it's documentations and also trying out it out, finally decided to switch the from the "django-app-engine-django" helper to the "Django-nonrel" port.Although it doesn't yet support all of Django APIs out of the box, but still has support upto a certain acceptible extent. The best part seems to be the way in which the port is supposed to work. And being currently a very active project, it's future and prospect seems good. They're using the lastest version of Django and hacking it's core to get support for non-relational databases and the App Engine database backend.The manage.py looks loaded with many useful common features, other than just the regular ones. Now remote login python shell to the GAE application server is just too easy. Infact the remote feature can be used with it's other subcommands too.Overall, it seemed to be the most promising thing … -
IxC workshop May'10
Yesterday we organised another of our monthly workshops. Varied topics were presented and discussed. Brett presented his learning experience during his internship at the IxC. I presented ways for boosting one’s productivity with text expanding, apple scripts and automations. Thomas and Brett showcased some cool features respectively from the LESS CSS framework and Coffee script. George proposed ways for including javascript libraries into reusable Django applications. Greg organised a fun game, based on index cards and “rock-paper-scissors”-style plays, for the agile estimation of feature implementation. This is something we’re actually (seriously!) about to implement in some of our biggest client projects. Those workshops are a great way for the team to share knowledge and good tips and to stay on the edge of all the cool things out there. We’re planning to make them public at some stage, so stay tuned! -
Scratchy Start
Porting this Django application to Google App Engine is proving to be some pain!Initiallialy I had thought that it won't be much of a thing. And since the google-app-engine-django helper was already out there, I thought things won't be that much difficult.Started with including the Django development version, and I just realized that things might not be that easy. Had to switch back to Django 1.1.1 version, and after putting it in place of the SVN version, the helper can launch the django devlopment server, to say the least. The helper still fails in one of the tests it performs, but who cares, my app engine server is up and running and ready to serve Django.The Django Models had to be replaced with the App Engine Models. I'm using the Google App Engine backed datastore, as I'm not willing to spend for hosting yet. The views also had to changed due to the change in APIs from Django to App Engine. The development server is working pretty much fine, and after a little time, the local datastore is created using my simple python scripts.Now the deployment. It was too easy to get the files up here. But, the biggest problem. … -
Scratchy Start
Porting this Django application to Google App Engine is proving to be some pain!Initiallialy I had thought that it won't be much of a thing. And since the google-app-engine-django helper was already out there, I thought things won't be that much difficult.Started with including the Django development version, and I just realized that things might not be that easy. Had to switch back to Django 1.1.1 version, and after putting it in place of the SVN version, the helper can launch the django devlopment server, to say the least. The helper still fails in one of the tests it performs, but who cares, my app engine server is up and running and ready to serve Django.The Django Models had to be replaced with the App Engine Models. I'm using the Google App Engine backed datastore, as I'm not willing to spend for hosting yet. The views also had to changed due to the change in APIs from Django to App Engine. The development server is working pretty much fine, and after a little time, the local datastore is created using my simple python scripts.Now the deployment. It was too easy to get the files up here. But, the biggest problem. … -
This is a sample title
This is a sample content used for testing this new blogging application. The content is being used for testing my new Django application, codenamed as "ScratchBlog". Let's see how it goes through. -
This is a sample title
This is a sample content used for testing this new blogging application. The content is being used for testing my new Django application, codenamed as "ScratchBlog". Let's see how it goes through. -
Getting Random objects from a Queryset in Django
When providing related or suggested info to the user in a website, it’s a common practice to obtain a random set of items. To do this in django the “usual” way is: Book.objects.all().order_by('?')[:10] The above code, sorts all books in a random order and then picks the first 10 objects. This approach is not really [...] -
Django aggregation and a simple GROUP BY
I love Django's aggregation framework. It very successfully abstracts the common aggregration tasks into a Pythonic syntax that sits extremely well with the rest of the ORM, and the documentation explains it all without a single reference to SQL. But sometimes that very abstraction gets in the way of working out what you want to do. One example of this happened to me today when I needed to do a sum of values grouped by a single value on a model - in SQL terms, a simple GROUP BY query. The documentation is very clear about how to do aggregations across an entire QuerySet, and annotations across a relationship. So you can, for example, easily do a sum of all the 'value' fields in a model, or a sum of all the 'value' fields on a related model for each instance of the parent model. But the implication is that these are the only things you can do. So I was left wondering if I had to create a dummy related model just to contain the unique values of the field I wanted to group on. In fact, what I wanted to do was clearly documented, but because of the … -
Django aggregation and a simple GROUP BY
I love Django's aggregation framework. It very successfully abstracts the common aggregration tasks into a Pythonic syntax that sits extremely well with the rest of the ORM, and the documentation explains it all without a single reference to SQL. But sometimes that very abstraction gets in the way of working out what you want to do. One example of this happened to me today when I needed to do a sum of values grouped by a single value on a model - in SQL terms, a simple GROUP BY query. The documentation is very clear about how to do aggregations across an entire QuerySet, and annotations across a relationship. So you can, for example, easily do a sum of all the 'value' fields in a model, or a sum of all the 'value' fields on a related model for each instance of the parent model. But the implication is that these are the only things you can do. So I was left wondering if I had to create a dummy related model just to contain the unique values of the field I wanted to group on. In fact, what I wanted to do was clearly documented, but because of the … -
Gunicorn / Django Debian init script
This is a simple Debian init.d script for my self-hosted Django/Gunicorn websites. Note that it runs inside a virtualenv (my installed Django versions are different in each virtualenv). If you have questions: comment this post! #!/bin/sh ### BEGIN INIT INFO # Provides: seismic_web # Required-Start: $local_fs $syslog # Required-Stop: $local_fs $syslog # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: Gunicorn processes for seismic_web ### END INIT INFO # www-data is the default www user on debian USER=www-data NAME="seismic_web" GUNICORN_RUN="gunicorn_django" # Confdir: the Django project inside the virtualenv CONFDIR="/home/thomas/seismic_web/seismic_web" VENV_ACTIVATION=". ../bin/activate" RETVAL=0 # PID: I always name my gunicorn pidfiles this way PID="/tmp/gunicorn_"$NAME".pid" # source function library . /lib/lsb/init-functions start() { echo "Starting $NAME." cd $CONFDIR; su -c "$VENV_ACTIVATION; $GUNICORN_RUN" $USER && echo "OK" || echo "failed"; } stop() { echo "Stopping $NAME" kill -QUIT `cat $PID` && echo "OK" || echo "failed"; } reload() { echo "Reloading $NAME:" if [ -f $PID ] then kill -HUP `cat $PID` && echo "OK" || echo "failed"; fi } case "$1" in start) start ;; stop) stop ;; restart) reload ;; reload) reload ;; force-reload) stop && start ;; *) echo $"Usage: $0 {start|stop|restart}" RETVAL=1 esac exit $RETVAL -
Deploying Django project with gunicorn and Nginx
Easy and fast deployment with gunicorn - a WSGI Python HTTP server and super fast and scalable Nginx server. -
Django Staging Server: Apache Configuration
In this post, I'd like to talk a little about how my staging server (called Kaylee, after the character from Firefly), is configured to run the multiple Django projects that I have on the go. A lot of the other articles I have read on this subject use mod_python but my server is configured to [...] -
Installing GeoDjango Dependencies with Homebrew
Installing GeoDjango Dependencies with Homebrew. brew update && brew install postgis && brew install gdal -
Installer Django dans un environnement Python virtuel avec pip, virtualenv et virtualenvwrapper
Ce billet résume les étapes nécessaires pour installer un ou plusieurs environnements de développement Django fonctionnels, portables et faciles à maintenir sous Mac OS X. Même si Django est un framework relativement simple à installer, lorsqu’il s’agit de développer plusieurs projets mettant en œuvre différentes versions de ce dernier ou de librairies tierces nécessaires pour assurer son bon fonctionnement, le casse-tête peut rapidement devenir ingérable si l’on ne prend pas garde à bien isoler le contexte applicatif dans un environnement dédié, isolé du reste du système. Concrètement, imaginons que j’ai deux projets Django : Le projet A utilise Django 1.2-DEV, django_toolbar en version 0.8.3 et Python 2.6 Le projet B utilise Django 1.1 et Pinax en version 0.6 tournant avec Python 2.5 Impossible dans ces conditions d’utiliser une version unique de chacune des librairies installées sur le système (et non, l’utilisation de liens symboliques et de préfixes n’est pas une solution acceptable sur le moyen/long terme). Aussi, découvrant progressivement la richesse de l’écosystème Python, je n’ai pas manqué de m’extasier devant la puissance et la simplicité d’outils tels que pip, virtualenv et virtualenvwrapper pour répondre à ces questions. pip, un installeur de paquet simple et efficace D’aucuns de ceux qui … -
django-site-gen, a tool for automating site creation
Most django sites I create have quite a lot in common. Beyond the handful of files generated by django-admin startproject, my projects all have a database, wsgi file, apache and nginx confs, static media and templates. All these building blocks of a site vary very little from project-to-project. django-site-gen allows you to automate the creation of the stuff that doesn't vary. -
Extending Settings Variables with local_settings.py in Django
I discovered this hacky way to use the local_settings trick to extend and/or override values in the main Django settings file today. Some projects use a "reverse" version of the local_settings trick (which is explained below), whereby the main settings file becomes settings_local.py or something similar, which first imports settings.py, and then extends or overrides [...] -
stackoverflow, stackexchange 2.0 oh my!
The problem It is quite amusing, how the experts-exchange killer stackoverflow.com is becoming something similar. Ever since StackOverflow started, people wanted to make their own sites for similar Q&A types of sites. Various topics could benefit from the similarly formatted Q&A sites. Unfortunately the SO team has not really been very open to open-sourcing it's source code. First they tried to make some bucks from selling it, thanks to the business mind of Joel Spolsky. However not all developers were eager to shell out $130/month for having their own little stackoverflow clone. So then, SO team, figured that they will never make big money by just having 4 paid sites (as that's all they managed to sell I think). What to do, what to do? This is where stackexchange 2.0 comes in. They together with a community (who are mostly developers) will "approve" the topics for the sites they think are worthy, and will host it themselves. Advanges? Ad revenue. Disadvantages? You can't really start your own. Even if your idea is great it may get downvoted by the community. After all - they are a community of developers, not say mechanics. The solution Free Django based Open Source Q&A … -
Idea for a simple task queue
cue is a simple queue abstraction along the lines of the command pattern, and provides django apps with a way to decouple the creation of a request from its execution. -
Damn foreign keys, stealing our jobs and women
Django has support for Generic Foreign Keys, which let you reference one model instance from another, without knowing up-front what that model type is. The classic use for something like this is for a commenting system; you need generic foreign keys – or something like them – because you wouldn't want a commenting system that only worked with a single model. If you have ever used generic foreign keys in Django, you will know that it is not quite transparent to the developer; a little effort is required to manage the various content types. I'll present here an alternative method to achieve this late binding of foreign keys that doesn't require storing the type of the object (as generic foreign keys do) and is completely transparent to the developer. I'm sure I'm not the first to think of this method, but I haven't yet seen it used in other Django projects. Rather than store the type of object in a separate field, we can create a new model for each foreign key type we want to reference. For example; lets say we have a Rating model, and we want to rate Articles and Images – we could do this by …