Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Gunicorn on apache: zero length fix
I recently switched one of our django sites over from apache+mod_wsgi to apache(+mod_proxy)+gunicorn. The advantage of gunicorn is that every site runs in its own process instead of everything running within one apache. When a site barfs, you can at least see the culprit when you type "top". Oh, and the speed seemed higher. (For an introduction on gunicorn, see my summary of the gunicorn talk at last year's djangocon.eu). But today a colleague using IE8 couldn't load the PNG images. And in my log I'd get "connection reset by peer" errors out of gunicorn. I had no problems in firefox. Assumption: perhaps django's gzip middleware messes things up. I've seen gzip-related errors before. Never had a problem with it in django, but worth a try. So I disabled it. IE8 failed to work as before, but now also firefox didn't load the images. They came in as zero-length responses! The advantage: now I could debug it myself. I did a wget -S on the server itself to take a look at the headers as close to the site as possible. First a request to gunicorn running on port 10003 (some lines omitted as they're not relevant): Connecting to localhost|127.0.0.1|:10003... … -
South migrations for geospatial field types
I wanted to create a south migration for one of my django apps. An app with geospatial field types. Oops: $> bin/django schemamigration lizard_opendap --initial ! Cannot freeze field 'lizard_opendap.point.geom' ! (this field has class django.contrib.gis.db.models.fields.PointField) ! Cannot freeze field 'lizard_opendap.line.geom' ! (this field has class django.contrib.gis.db.models.fields.LineStringField) ! South cannot introspect some fields; this is probably because they are custom ! fields. If they worked in 0.6 or below, this is because we have removed the ! models parser (it often broke things). ! To fix this, read http://south.aeracode.org/wiki/MyFieldsDontWork Weird. I googled a bit and found out that support for those geom fields was added some years ago. So it should work. The solution: I forgot to add 'django.contrib.gis' to INSTALLED_APPS in settings.py. I thought that entry wasn't needed anymore, so I tend to leave it out. (Iirc, it used to be necessary because of geospatial databases, but those databases work just fine without adding django.contrib.gis to INSTALLED_APPS now). Yep, now it works: $> bin/django schemamigration lizard_opendap --initial + Added model lizard_opendap.Setting + Added model lizard_opendap.SourceModel + Added model lizard_opendap.Scenario + Added model lizard_opendap.ModelResult + Added model lizard_opendap.Point + Added model lizard_opendap.PointValue + Added model lizard_opendap.Line + Added model lizard_opendap.LineValue … -
Chef scripting quick start
This post is about Chef. Chef is a big odd but very powerful piece of software. You'll probably find it extremely useful for your deploy tasks - as soon as you can understand it. -
New house
Big news for us: if everything goes right, we'll be moving in one or two months! I never expected it to go this fast. We wanted a slightly bigger house in order to give both our kids (boy + girl) a separate room. So mostly the same size, but with one extra room. And a slightly bigger garden to house our bikes wouldn't hurt. Two months ago we started looking at houses for rent. In the Netherlands every region has a system of doling out houses from the so-called "social housing rental corporations". Based on the amount of time you wait. You can sign in on three houses per two weeks and the longest waiting time wins. That's how we got our current house. Aforementioned housing system only is allowed up until a certain income. We're above that margin, so we had to look for the more expensive rental houses that are handled outside the social rent system. The advantage: they're available earlier. The disadvantage: they're more expensive. Three weeks ago we subscribed ourselves at two housing agencies for rental houses. And I booked an appointment at a mortgage agent just in case it was possible for us to buy … -
Migrating django(-cms) from sqlite to postgres
We've got a django-cms site that started out on sqlite. Now we're adding GIS shapefiles so we wanted to move to postgres/postgis. Ok, switch over the DATABASES definition in settings.py, make a fixture and load it, right? Ahem, no. There were a couple of problems, partially with our code, partially django-cms, partially django. Some solutions below might not be needed in every case, but I'm just going to list everything in the hope that it helps someone. South migration dependencies Lots of our code uses south for database migrations. But when creating our database from scratch, "migrate" would complain that a certain table of application A didn't exist yet when migrating application B. Uh oh, a dependency. Turns out that's easily solved. In the failing migration step, just add a dependency on the missing application's relevant step: ... class Migration(SchemaMigration): depends_on = ( ("application_a", "0001_initial"), ) def forwards(self, orm): ... After that, all migrations run fine. Small sqldiff limitation We've got django-extensions in our projects. One of the handy extra management commands it provides is "sqldiff" (so manage.py sqldiff or, as we use buildout, bin/django sqldiff). (The best extension is "graph_models" which creates a picture of your model structure). We … -
Open Source Repositories Have moved
We’ve moved our repositories yet again! First we hosted our repositories here on opensource.washingtontimes.com, then we moved them to http://github.com/washingtontimes. We’ve decided to move the projects (over 40 of them) to our Calloway project’s GitHub account. Please excuse the confusion. We feel this will keep them available for a long time. -
Classes are not just namespaces
There is a mistake that Python developers make every now and then. If they also happen to be authors of some framework, they can get away with telling us that this is the very framework's way and suggesting an ugly (yet "frameworky") workaround. But you can't, so please don't do this to us. A little rant on the "instance greed" and a reason of `View.as_view()` method in Django's class based views classes in the blog post. -
Django job at Net Communities
Net Communities are looking for a Python/Django developer to work on an in-house project. It's a contract that would require some on-site work, but they would also consider a full-time developer for the right individual. If you are interested, get in touch with Andy Evans. -
Django job at Net Communities
Net Communities are looking for a Python/Django developer to work on an in-house project. It's a contract that would require some on-site work, but they would also consider a full-time developer for the right individual. If you are interested, get in touch with Andy Evans. -
Django job at Net Communities
Net Communities are looking for a Python/Django developer to work on an in-house project. It's a contract that would require some on-site work, but they would also consider a full-time developer for the right individual. If you are interested, get in touch with Andy Evans. -
Creating a Read-only Mirror for your GitHub Server
-
django-urli18n
Even I released django-urli18n already two weeks ago, I didn't find the time to actually announce it. So here it is: What is django-urli18n? A reusable Django app to display the current activated language in the URL. Features - different ways to show the language in the URL: in the path (for example www.example.com/en/home/) or in a query string (for example www.example.com/home/?lang=en) - simple to use and include into new or existing Django projects Where to get it? Check out the project page on Github. -
Django Canvas - Planned Feature List
Hi folks,I am really pleased that other developers have found Django Canvas useful and interesting. I had the idea of building this project at PyCon 2011, Atlanta, where I discussed it with other developers. Now that I have finally built it, I am happy that my efforts have been worth something. :)I have had a lot of great advice from many different sources, especially after superchink submitted the project on Hacker News. Useful channels for feedback have been: email, twitter, hacker news, reddit and convore.Despite the Google Code Jam taking up some time today, I have put together a list of features I'm planning for the next release.Feature listAPI for creating, downloading packages + user authenticationSSL (in case sensitive information is used within the configurations)Ability to add packages from djangopackages.com and git/mercurial/svn repositoriesPackage links and descriptions need to be accessible on the home pageUsers will be able to have accounts, save their settings and have their private base projects savedPublic base projects might be a useful addition to the communityAbility for django package owners to make their packages compatible with Django CanvasFabric supportCustomization of project structureLoading modal box to prevent user from downloading multiple archives at the same time.It would … -
Voxy.com Launch!
Voxy helps you learn a language from life. That means, doing things you would do anyway but learn a language while you do it. Like reading about the NFL lock-out in Spanish. If you're learning English, an English version is also available here. The iPhone app has reached #1 in the AppStore for education apps in 14 countries. Android app is coming any day now too. Both apps support location based learning. Are you near a bank and need to figure how to linguically maneuver through a transaction? Voxy can help! One of the fun things about building this site in Django is how well Django handles changes in company direction and the associated functionality. The app has iterated, very quickly, through many different versions and Django has handled everything in stride. The site and associated mobile APIs were created in Django 1.2 using PostgreSQL 9 along with the usual suspects of South, Sentry, django_extensions, debug toolbar, boto, celery with RabbitMQ and also dbgettext, photologue, django-rosetta and newcache. APIs we use are from SimpleGEO, Twilio (SMS), WordNIK, Recurly. And everything is deployed on Linode except for a server to translate audio using Natural Reader 10 running on Windows @ Amazon … -
Voxy Launch!
Voxy helps you learn a language from life. That means, doing things you would do anyway but learn a language while you do it. Like reading about the NFL lock-out in Spanish. If you're learning English, an English version is also available here. The iPhone app has reached #1 in the AppStore for education apps in 14 countries. Android app is coming any day now too. Both apps support location based learning. Are you near a bank and need to figure how to linguically maneuver through a transaction? Voxy can help! One of the fun things about building this site in Django is how well Django handles changes in company direction and the associated functionality. The app has iterated, very quickly, through many different versions and Django has handled everything in stride. The site and associated mobile APIs were created in Django 1.2 using PostgreSQL 9 along with the usual suspects of South, Sentry, django_extensions, debug toolbar, boto, celery with RabbitMQ and also dbgettext, photologue, django-rosetta and newcache. APIs we use are from SimpleGEO, Twilio (SMS), WordNIK, Recurly. And everything is deployed on Linode except for a server to translate audio using Natural Reader 10 running on Windows @ Amazon … -
Using virtual machine (vagrant) for you web development
In my opinion, environments on the development machine and production machine must be as close to each other as possible. But installing Postgres, Solr and whatnot on your local machine is a terrible option, and they quickly become unmanageable. We have a solution for that! -
Minor updates and API changes
Maybe you noticed that we've started to work on our projects again. ;) We unsurprisingly (:P) passed our final physics exams and are ready to work on NoSQL development again. Waldemar has already started to do some work in order to get our efforts into Django trunk. In the meantime I've started to work on some bug reports concerning django-dbindexer and nonrel-search. Both now have a dependency on django-autoload which ensures the loading of indexes or signal handlers before any request is processed. As a consequence, you have to adapt your code if you make use of django-dbindexer or nonrel-search. The documentation has been changed in order to reflect these changes. Maybe we'll take a few days off to go on vacation. Then, we'll come back and continue improving the way of NoSQL development. Leave a comment -
How to search with row level permissions?
Searching on a site where everyone has access to only some content can be tricky to implement. I'm discussing here several basic concepts about row level permissions and how to implement full-text search without hacking and complicated code. -
Haystack 1.2 Released
Haystack 1.2 Released -
Preventing django-cms's toolbar from showing on certain urls (updated 2011-05-23)
Django-cms has a toolbar at the top of the page when you're editing. Handy for adding/editing pages or for going to the admin interface. It does that by means of some django middleware that injects (mostly) javascript code at the top of your page. Fun. Only, you don't want it everywhere if you've got non-django-cms parts of your site. See for instance a recent mailinglist discussion. There's currently no build-in way to disable it, but doing that yourself turned out to be pretty simple. Updated: this didn't work. In my site, I originally added a mysite.hacked_toolbar.py: from cms.middleware.toolbar import ToolbarMiddleware START_OF_EXCLUDED_URLS = ['/map/', '/share/'] # ^^^ Modify to your needs. class HackedToolbarMiddleware(ToolbarMiddleware): """Hacked version of django-cms's toolbar middleware. This modification prevents /map and /share urls from getting a toolbar as django-cms's toolbar contains conflicting jquery stuff, leading to javascript errors in our own part of the application. To use it, instead of 'cms.middleware.toolbar.ToolbarMiddleware', use 'mysite.hacked_toolbar.HackedToolbarMiddleware' in your ``MIDDLEWARE_CLASSES``. """ def show_toolbar(self, request, response): """Return False on excluded urls, use original method otherwise. """ for url in START_OF_EXCLUDED_URLS: if request.path.startswith(url): return False return ToolbarMiddleware.show_toolbar(self, request, response) Afterwards, in your settings.py I told you to go to the MIDDLEWARE_CLASSES. And switch 'cms.middleware.toolbar.ToolbarMiddleware' … -
Django and Whiskey.
No, not programming whilst inebriated. Although the effects of theBallmer Peakare well known.I mean usingwsgiand Apache together withDjango.But, perhaps, I should explain my (current) layout of projects.I now use:/path/to/project/ .git .gitignore project_name/ urls.py settings.py production_settings.py [...] apache/ project_name.conf django.wsgi env/ [...] sitestatic/ requirements.txt fabfile.pyThis allows me to have revision control of things meta to the project and of the project itself.This setup is relatively new, I've only been using it in about 4 projects now.Which meant that my wsgi file had to be slightly modified.This took me alotlonger than I expected to get going. But if you decide to use a layout similar to mine, this might help.import os import sys import site ## Assumptions: # Assume that the Django project and the environment are at the same level. # i.e. # /home/ # /<project root>/ <- * # /<project name>/ <- * # /apache/ # django.wsgi # production_settings # /env/ # /lib/ # /pythonX.Y/ # /site-packages/ <- * # /sitestatic # # Directories marked with '<- *' need to be imported for everything to work PROJECT_NAME = "control" PYVER = "%d.%d" % (sys.version_info[0], sys.version_info[1]) APACHE_DIR = os.path.abspath(os.path.dirname(__file__)) PROJECT_ROOT = os.path.abspath(os.path.join(APACHE_DIR, "..")) site_packages = os.path.join(PROJECT_ROOT, 'env/lib/python%s/site-packages' % PYVER) site.addsitedir(os.path.abspath(site_packages)) sys.path.insert(0, … -
You should use django-haystack like this
There is an annoying API mistake in django-haystack, leading to bugs and hacks. In this article, I tell you about the *only* way you should use django-haystack, which will save us all a lot of time. -
You should use django-haystack like this
There is an annoying API mistake in django-haystack, leading to bugs and hacks. In this article, I tell you about the *only* way you should use django-haystack, which will save us all a lot of time. -
Three easy rules about parts of code of apps within django project
Very easy convention about parts of code of apps within django project:Any functions which aren't views shouldn't be placed in views.pyAny functions related to work with forms should be in forms.py and be method of the form classAny function which used by more than one view/form/function should be saved in utils.pyUseful links: Django Reusable App Conventions , Django Application Conventions -
Admin django, deux petits tips pour les change_list
L'admin django est vraiment un bonheur pour la productivité. On peut faire plein de choses en moins de temps qu'il n'en faut pour écrire le descriptif des choses en questions. Après avoir passé quelques heures à farfouiller dans la doc et à faire quelques tests, je me suis dit qu'il n'y avait pas de raisons ...