Today was added a new feature to django ORM. Now it supports references to fields in filters expressions. Just checkout the SVN version and enjoy it.
Before this update, queryset could be filtered only by absolute values.
Will generate somthing like this:
SELECT * FROM table_name WHERE field = 'absolute value';
Now you can filter by another’s table field value.
Will generate something like this:
SELECT * FROM table_name WHERE field = another_field;
The feature also supports arithmetical operations in the lookups so you can do filters where the views_number is twice as big as the comments_number.
Will generate a SQL like this:
SELECT * FROM table_name WHERE views_number = comments_number*2;
It’s a very good feature. So, checkout the SVN version and take a look at docs/topics/db/queries.txt to know more about this.
I found out that the documentation of the MeioUpload was translated to other languages and I want to announce it. Here are the links:
Django has the good feature of internationalization. It’s very simple to use that it generates the
.po files automatically from your project. All you have to do is complete the
.po file with the translated text. To create these files, all you have to do is create a folder in your project called
locale and run the command
./manage.py makemessages -l <your-locale>. That’s very easy, but I realized that it don’t get the string inside your external apps. So, after some search in internet, i found a way to get this file with the app’s strings. And, as all in django must be, it is a pluggable way to solve the problem.
All you have to do is create a folder named
locale inside your app’s folder and run the command
django-admin.py makemessages -l <your-locale> and it will create the file for you. To compile the messages, use the command
django-admin.py compilemessages -l <your-locale>
That’s it, as simple as everything in django.
The aggregation is already available in Django SVN version. Now, it’s possible to do things such count authors of all book entries, count comments os all post entries, sum values of all sales to a client and much more.
Here is the official documentation of this feature: http://docs.djangoproject.com/en/dev/topics/db/aggregation/