django

Workaround for Django 1.4 -> Django 1.6 message cookie error
The messages cookie format has changed in Django 1.5. However, support for the old format has been removed from Django 1.6 which means that if you migrate from Django 1.4 to Django 1.6 directly, you may get an unexpected and hard to solve IndexError:   Exception Type: IndexErrorException Value:list index ...
Synchronize a postgresql database to a different user for demo purposes
How can you easily sync two databases?
Getting started with Django and AngularJS
AngularJS is a fantastic javascript framework. But it requires some tweaks if you want to use it in combination with Django.
Adding css classes to formfields in Django Templates
I'm in the process of making two.bootstrap support Bootstrap 3. A lot has changed but one of the most significant changes may be the requirement that form controls (like input) must have a class="formcontrol" to be rendered properly.  When using Django forms, it's often unavoidable to have to construct the ...
Django trick: getting a readable traceback
When working/debugging with Django, there may be cases where you get the full (debug) HTML error template. For example, when using pdb on client code that invokes a django view.It's really hard to get the actual error from such a template (without a browser). The following code snippet may be ...
Prefix substring matching for django haystack / solr
If you're using django haystack with SOLR (both fantastic products) and you want your queries to also match partially against words, e.g. search "foo" will match "foo", "foobar", "food", then the following might be a solution.SOLR supports prefix substring matching through the EdgeNGramFilterFactory. You will need to add this to ...
boosting generic queries with Django Haystack / SOLR
More Django/Haystack/SOLR fun today: boosting a specific field on a generic query. Now, that would seem trivial using the "boost" option on a searchfield, but it isn't. It turns out this option only works if you explicitly query on the boosted field. Consider the following definition:class SomeIndex(SearchIndex): text = CharField(document=True, use_template=True, ...
Django and Travis Continuous Integration
Travis-CI for a buildout/Django project is not as trivial as it seems...
More SOLR and eDismax parser fun
It turns out the eDismax plugin is quite broken in SOLR 3.6
Template layers / skins for Django
With Django I often have cases where I want to serve different templates based on certain request-specific criteria (usually the hostname used for the request). For example Different "skins" for different domains A different "visitor skin" all together (while the backoffice has a generic admin skin) A/B testing You can ...
Mixing AngularJS and Django Template placeholders
I've blogged before on how to use AngularJS with Django, who both share the same {{ }} placeholders. The trick there was to keep using {{ }} for Django, and <[ ]> (or any other combo) for AngularJS.   This works well but there's a gotcha: What if you depend ...