Django community: Community blog posts RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Jacob Kaplan-Moss on DevOps
Jacob gave a talk at the Boston Django Meetup this month on the topic of DevOps — The role of the developer and the role of sysadmin are merging, and it is a good thing. This idea certainly resonate with me. I started my career as a DevOps by necessity — I worked with a [...] -
My Accidental Connection with Senator Ted Kennedy
Being Chinese in Boston, I always hear positive stories about the late Senator Ted Kennedy helping immigrants. In addition, I agree with most of his political views, he seemed like a good Senator. After learning of his death, I felt we had lost a great man. I added one of his biographies to my Amazon [...] -
I am in the NY Times, sorta
Check out the NYTimes article on WilsonDailyPrep. We at Imperial Consulting did the application, using Django and Python. It is a great service and a lot of fun to work on (my own vocab and grammar has gotten better, the Math quizzes are too easy). I am glad it is getting the big time publicity [...] -
How to actually make LocalSolr work
Today I've been working on integrating geospatial search with our upcoming DISQUS Search product, which happens to rely on Solr. It didn't take much work before I stumbled upon LocalSolr, which seems to be the defacto gis implementation. The docs were fairly brief, but it seemed easy to get up an... -
The Definitive Guide to Installing Django on Ubuntu
Make sure you install django. -
The Definitive Guide to Installing Django on Ubuntu
Make sure you install django. -
Resolutions for 2011
Travel to Europe again.Travel to Asia or Africa.Visit a Disney park.See a place in the USA I've never been.Drop the waist size 2 inches and not break any bones.Go to Pycon and present or teach.Go to DjangoCon and present or teach.Present at LA DjangoContinue my Muay Thai and Capoeira studies, get back into Eskrima, learn some more BJJ, and practice the forms I know.Work out at least three times a week.Go back east and teach martial arts for a day.Finish some outstanding legal proceedings.Launch a site that does cool stuff and somehow brings in money.Get to the point with LISP where I can do cool stuff in it without needing a textbook.Blog once a week. That is at least 52 blog entries!Explain why I wrote Diversity Rocks. -
Django-UserGroup Hamburg jetzt mit festen Terminen
Ab 2011 trifft sich die Django-UserGroup Hamburg (dughh) immer am zweiten Mittwoch in allen ungeraden Monaten um 19:30 Uhr. Die nächsten drei Termine sind also: 12. Januar 09. März 11. Mai Alle Termine sind über den folgenden Link als Google Kalender verfügbar: http://bit.ly/bL1kqz Um den Kalender im eigenen Google Kalender hinzuzufügen kann man folgende ID benutzen: npmdepcp52p5futhnoo0cgacg0@group.calendar.google.com Um den Kalender in anderen Kalender-Programmen einzubinden kann man folgenden Link für das iCal Format benutzen: http://www.google.com/calendar/ical/npmdepcp52p5futhnoo0cgacg0%40group.calendar.google.com/public/basic.ics Abgesehen von den Terminen ändert sich erstmal nichts. Die Treffen finden weiterhin bei CoreMedia statt. Mehr Informationen gibt es im Wiki des Deutschen Django Vereins. -
2010: A Year in Review
2010 was a great year for RevSys and for Jacob and I, both personally and professionally. Here are some of the highlights: Jacob gave a ton of training classes around the US in cities such as NYC, Boston, Los Angles, and Atlanta. Between his training schedule and speaking engagements he managed to log close to 60,000 miles of travel hitting 31 cities in 4 countries this year. I'd list links to all of Jacob's talks this year, but unfortuantely our webserver doesn't have enough storage for that large of a list! (Ok I'm lying, I'm just lazy and running late for a New Year's Eve party.) We gave a half day tutorial at OSCON on deploying Django. I gave a talk at DjangoCon and we helped sponsor the conference this year. It was also the first time I got to meet Steve Holden We were able to work with some of the best developers other there this year on projects, people such as Malcolm, Danny, Daniel, and Travis. Danny even camped out with us at Chez Revsys for a few months while he taste tested Lawrence. We refreshed our site with the amazing help of Greg Newman and Ed Frazier. … -
Django and Bleach
Bleach is a HTML whitelist and sanitizer library written by James Socol. At mozilla we use it on the addons and support sites. Chances are you'll need it on pretty much any site that accepts user input, ensuring that the HTML you are outputting is nice and safe. Under the hood bleach uses the html5lib. As an aside, I've been running html5lib sanitisation using a homegrown library on App Engine for a while now and it's been great. Installing bleach is as simple as: pip install bleach The place to do user validation is a form, so let's take a simple model and form combination: from django.db import models class Todo(models.Model): text = models.CharField(max_length=255) from django.forms import ModelForm from bleach import Bleach from todo.models import Todo bleach = Bleach() class TodoForm(ModelForm): def clean_text(self): return bleach.clean(self.cleaned_data.get('text', '')) class Meta: model = Todo And that's it, our Todo model is now going to be nicely sanitised (assuming you use a django form for validating all user input, which you should do). So here's a quick test: import unittest from todo.forms import TodoForm class TestBleach(unittest.TestCase): def test_todo(self): data = "<b>bold</b> <script>alert('hello')</script> " expect = "<b>bold</b> &lt;script&gt;alert('hello')&lt;/script&gt;" form = TodoForm({'text':data}) assert form.is_valid() assert form.cleaned_data['text'] … -
Django-easy-maps, c’est comme google maps, mais dans ton site
Cette année se finira comme elle a commencé, en bossant et avec beaucoup moins de temps que ce que j'aimerais en avoir. Il y a pas à dire, il faut vraiment que je me remette à jouer au loto, histoire de pouvoir rêver à un jour, avoir tout le temps que j'aimerais avoir. Mais ne ... -
Autocompletion for Django models using Solr, Redis or SQL
One of the nicest UI's around when dealing with a large dataset is a good autocomplete. Facebook's search is a great example, same for Netflix, and recently Google launched "Google Instant", which returns search results as you type. Autocomplete can really complement hierarchical drill-down search (which is useful for discovery), as the goal of autocomplete is more for helping users find something they already know about with a minimum of effort. django-completion The goal of django-completion is to make adding autocompletion to your django project super easy. It follows the by-now-standard pluggable backend/registry approach, so its on you to write "providers" for the models you want to enable autocomplete on. Luckily, there's only a handful of methods you need to implement. Supposing you wanted to allow autocomplete on users, here's what a "User" provider might look like: syntax:python from django.contrib.auth.models import User from completion.sites import AutocompleteProvider, site class UserProvider(AutocompleteProvider): def get_title(self, obj): """This is the phrase that will be 'autocompleted'""" return obj.username def get_pub_date(self, obj): return obj.last_login def get_data(self, obj): """ Any arbitrary data you want stored in the index, which will be returned when a search is performed """ return { 'username': obj.username, 'email': obj.email, 'avatar_url': obj.profile.avatar, 'profile_url': obj.get_absolute_url() … -
Смена места
Пятница 24 декабря была моим последним днём работы в московском офисе Яндекса. Как многие уже в курсе, мы с Алёной переехали в Сиэтл. Она будет работать в Bing, а я получил от Яндекса чудесное предложение быть внештатным консультантом, которое с радостью и принял. Было Моя главная работа в Яндексе заключалась в руководстве группой разработчиков, которая занималась разными проектами, но была объединена по технологическому признаку: мы пишем веб-сервисы на Питоне. Была ещё дополнительная, хоть и не менее важная, часть работы — поддержка и развитие питоньего стека технологий: Джанго, утилиты, сборочный процесс, документация. Должен признаться, этой частью работы мне совершенно сознательно приходилось жертвовать в пользу менеджмента. Стало Смена места жительства автоматически означает, что заниматься менеджерской частью я уже не смогу. Поэтому моя прежняя дополнительная нагрузка просто станет основной. И это как раз то, что мне так нравится. Мне давно хочется навести порядок в джанговском хозяйстве в Яндексе, довести его до современного уровня и автоматизировать, чтобы не тратить лишних телодвижений на инфраструктуру, демплоймент, мониторинг… Ещё одно дело, которое я не собираюсь бросать — это работа над различными API для Яндексовых сервисов. Пока что ни одно из них не стало хитом, но у меня есть идеи о том, как это можно исправить. Документирование, реализация … -
Смена места
Пятница 24 декабря была моим последним днём работы в московском офисе Яндекса. Как многие уже в курсе, мы с Алёной переехали в Сиэтл. Она будет работать в Bing, а я получил от Яндекса чудесное предложение быть внештатным консультантом, которое с радостью и принял. Было Моя главная работа в Яндексе заключалась в руководстве группой разработчиков, которая занималась разными проектами, но была объединена по технологическому признаку: мы пишем веб-сервисы на Питоне. Была ещё дополнительная, хоть и не менее важная, часть работы — поддержка и развитие питоньего стека технологий: Джанго, утилиты, сборочный процесс, документация. Должен признаться, этой частью работы мне совершенно сознательно приходилось жертвовать в пользу менеджмента. Стало Смена места жительства автоматически означает, что заниматься менеджерской частью я уже не смогу. Поэтому моя прежняя дополнительная нагрузка просто станет основной. И это как раз то, что мне так нравится. Мне давно хочется навести порядок в джанговском хозяйстве в Яндексе, довести его до современного уровня и автоматизировать, чтобы не тратить лишних телодвижений на инфраструктуру, демплоймент, мониторинг… Ещё одно дело, которое я не собираюсь бросать — это работа над различными API для Яндексовых сервисов. Пока что ни одно из них не стало хитом, но у меня есть идеи о том, как это можно исправить. Документирование, реализация … -
Смена места
Пятница 24 декабря была моим последним днём работы в московском офисе Яндекса. Как многие уже в курсе, мы с Алёной переехали в Сиэтл. Она будет работать в Bing, а я получил от Яндекса чудесное предложение быть внештатным консультантом, которое с радостью и принял. Было Моя главная работа в Яндексе заключалась в руководстве группой разработчиков, которая занималась разными проектами, но была объединена по технологическому признаку: мы пишем веб-сервисы на Питоне. Была ещё дополнительная, хоть и не менее важная, часть работы — поддержка и развитие питоньего стека технологий: Джанго, утилиты, сборочный процесс, документация. Должен признаться, этой частью работы мне совершенно сознательно приходилось жертвовать в пользу менеджмента. Стало Смена места жительства автоматически означает, что заниматься менеджерской частью я уже не смогу. Поэтому моя прежняя дополнительная нагрузка просто станет основной. И это как раз то, что мне так нравится. Мне давно хочется навести порядок в джанговском хозяйстве в Яндексе, довести его до современного уровня и автоматизировать, чтобы не тратить лишних телодвижений на инфраструктуру, демплоймент, мониторинг… Ещё одно дело, которое я не собираюсь бросать — это работа над различными API для Яндексовых сервисов. Пока что ни одно из них не стало хитом, но у меня есть идеи о том, как это можно исправить. Документирование, реализация … -
Recap of 2010
This has been an unforgettable year. I can't believe all this stuff happened. I've moved many times, met wonderful people, and seen my life change in ways I could have never predicted.The good:Met a whole new bunch of wonderful people - relationships to last a lifetime. Arthur, Audrey, Celso, Cody, Daniel, Jacob, Jeff, Lahn, Moriah, Skyler, Todd and others I'm certainly forgetting to my undying shame. Thanks for your awesomeness!Presented and taught at Pycon 2010.Had a blast in the blizzard of 2010.Prepped my house of 9 years for sale and sold it.Paid off my debts. I sleep so much better now.Left NASA after 5 years and 3 months for freelancing pastures. Thanks Eldarion LLC, Revsys LLC, Holdenweb LLC, and Bryan Klein. Being exposed to some of the incredible code and developers on these projects has made me a better developer. Show me more!Flew enough in the spring to put me ahead of notorious traveller James Tauber for about 2 months in sheer mileage accumulated.Got to reconnect with a cousin and met his lovely wife and handsome son. Also hung out with my Uncle Al and Aunt Sandra.Got a tour of Ames Research Center thanks to Michael Sims. He'll probably be presenting at Pycon!Attended … -
Database Routers in Django
-
Database Routers in Django
Whether you're doing master / slave, or partitioning data, when your product gets large enough you'll need the ability to route data to various nodes in your database. Django (as of 1.2) out of the box provides a pretty cool solution called a Database Router. Here at DISQUS we have a large set of... -
HIV Results, Birth Reminders, and Clinic Communication in Malawi
I recently returned from a 6 week trip in Malawi, where I was heavily involved in the implementation and deployment of Project Mwana, an Information and Communication Technology (ICT) project focused on Maternal and Newborn Child Health (MNCH). The project is currently running as a pilot in both Zambia and Malawi. This post is a ... -
Python interpreter tricks
John Anderson has documented some nice Python interpreter tricks on his blog. Including a .pythonrc.py file hack for Djangonauts: For Django developers when you load up the ./manage.py shell it is nice to have access to all your models and settings for testing: # If we're working with a Django project, set up the environment if 'DJANGO_SETTINGS_MODULE' in os.environ: from django.db.models.loading import get_models from django.test.client import Client from django.test.utils import setup_test_environment, teardown_test_environment from django.conf import settings as S class DjangoModels(object): """Loop through all the models in INSTALLED_APPS and import them.""" def __init__(self): for m in get_models(): setattr(self, m.__name__, m) A = DjangoModels() C = Client() See his post for more interesting Python tips. Me, I’m enabling autocomplete and automatic pretty-printing right now. Tagged: Django, Python -
Activation/Deactivation of python virtualenv upon entering a directory
It's not a new or original idea – I've heard about it from Dmitry Gladkov but as usual didn't remember details. So, I've created my own implementation of activation/deactivation of python virtualenv:#!/bin/bashPREVPWD=`pwd`PREVENV_PATH=PREV_PS1=PREV_PATH=handle_virtualenv(){ if [ "$PWD" != "$PREVPWD" ]; then PREVPWD="$PWD"; if [ -n "$PREVENV_PATH" ]; then if [ "`echo "$PWD" | grep -c $PREVENV_PATH`" = "0" ]; then source $PREVENV_PATH/.venv echo "> Virtualenv `basename $VIRTUALENV_PATH` deactivated" PS1=$PREV_PS1 PATH=$PREV_PATH PREVENV_PATH= fi fi # activate virtualenv dynamically if [ -e "$PWD/.venv" ] && [ "$PWD" != "$PREVENV_PATH" ]; then PREV_PS1="$PS1" PREV_PATH="$PATH" PREVENV_PATH="$PWD" source $PWD/.venv source $VIRTUALENV_PATH/bin/activate echo "> Virtualenv `basename $VIRTUALENV_PATH` activated" fi fi}export PROMPT_COMMAND=handle_virtualenvJust paste this code into your $HOME/.bash_profileand place .venvfile with declaration like below:VIRTUALENV_PATH=$HOME/.envs/sampleenvironmentAnd it should works like a charm. Script only for bash! -
Install and Use Django, MySQL, and VirtualEnv on Snow Leopard
Django mkdir -p ~/src svn co http://code.djangoproject.com/svn/django/trunk/ ~/src/django ln -s ~/src/django/django `python -c "from distutils.sysconfig import get_python_lib; print get_python_lib()"`/django ln -s ~/src/django/django/bin/django-admin.py ~/bin/django-admin.py PIP, mysql-python, virtualenv, virtualenvwrapper, Mercurial Download and install the MySQL package installer, then: easy_install pip pip install http://downloads.sourceforge.net/project/mysql-python/mysql-python-test/1.2.3c1/MySQL-python-1.2.3c1.tar.gz?use_mirror=cdnetworks-us-2 pip install virtualenv pip install virtualenvwrapper pip install mercurial (Note: we’re installing Mercurial because [...] -
Django-Tracking 0.3.5
I've finally gotten around to looking at a bunch of tickets that had been opened for django-tracking in the past year and a half or so. I feel horrible that it's really taken that long for me to get to them! Every time I got a ticket notification, I told myself, "Okay, I'll work on that this weekend." Many have weekends have passed without any work on any of my projects. I'm going to get better about that! Anyway, several fixes have gone into the latest version of django-tracking. Some have to do with unicode problems (thanks ramusus!). Others have to do with overall performance, while yet others have to do with overall stability. The first interesting change in this release is that django-tracking no longer relies on the GeoIP Python API. Instead it's now using django.contrib.gis.utils.GeoIP. I had hoped that this would remove the dependency on the GeoIP C API, but it appears that I was mistaken. Oh well. Perhaps the biggest improvement in this new release is the use of caching. With caching in place, the middleware classes don't slam the database nearly as badly as they used to. There's still more that could be done with caching … -
Django-Tracking 0.3.5
I've finally gotten around to looking at a bunch of tickets that had been opened for django-tracking in the past year and a half or so. I feel horrible that it's really taken that long for me to get to them! Every time I got a ticket notification, I told myself, "Okay, I'll work on that this weekend." Many have weekends have passed without any work on any of my projects. I'm going to get better about that! Anyway, several fixes have gone into the latest version of django-tracking. Some have to do with unicode problems (thanks ramusus!). Others have to do with overall performance, while yet others have to do with overall stability. The first interesting change in this release is that django-tracking no longer relies on the GeoIP Python API. Instead it's now using django.contrib.gis.utils.GeoIP. I had hoped that this would remove the dependency on the GeoIP C API, but it appears that I was mistaken. Oh well. Perhaps the biggest improvement in this new release is the use of caching. With caching in place, the middleware classes don't slam the database nearly as badly as they used to. There's still more that could be done with caching … -
BitField’s in Django