Django community: RSS
This page, updated regularly, aggregates Community blog posts from the Django community.
-
Смена места
Пятница 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
-
BitField's in Django
Today we're releasing another heavily used component from the DISQUS code base, our BitField class. While not a true BIT field (it uses a BIGINT), it still allows you the convenience of accessing the values as if they were bit flags. When I joined DISQUS about 7 months ago, we were using a Q-lik... -
Facebook aided registration in Django
How to use new Facebook registration tool to show and handle a registration form with data prepopulated from a Facebook account. -
Merry Christmas
Merry Christmas and a happy 2011, everyone! Actually we wanted to finish a little present, but December was just too full with other stuff. Looks like Thomas will have to play Santa in January. ;) This blog started more or less one year ago. Back then we still were on a blogspot subdomain. A few months later Django-nonrel was ready for hosting a simple site, so we moved everything on a custom domain (allbuttonspressed.com) hosted on App Engine with Django-nonrel. Now this blog has more than 700 subscribers and we really need to get some feedback from you, so we can improve our articles in 2011. Please help us by filling out this short survey. Thanks a lot! Have a nice Christmas and a successful 2011. Leave a comment -
A stateful problem
So, this week we dropped some security updates, which you should definitely check out if you haven’t seen them yet. We also released the first 1.3 beta, which is an important milestone since it means 1.3 is now feature-frozen and will get only bugfix and polishing work until the final release. Quite a few useful things made it in between alpha and beta, and a couple just barely slipped in under the wire. One ... Read full entry -
django-anonymizer released
An app to help protect your customers' data when in development. -
A stateful problem
So, this week we dropped some security updates, which you should definitely check out if you haven’t seen them yet. We also released the first 1.3 beta, which is an important milestone since it means 1.3 is now feature-frozen and will get only bugfix and polishing work until the final release. Quite a few useful things made it in between alpha and beta, and a couple just barely slipped in under the ... Read full entry -
Django model migrations with South: how-to migrate ForeignKey relation to ManyToMany
Yesterday I had an non-trivial for newbie South user issue: I need to migrate a big database table with existing FK relations to M2M relations and keep in safety all of existing data during migration.So, I hadn't figure out in documentation how I can do it without handmade migration code in forward method. Below I described how I've fixed it:1. Here is my initial model (sample), my application called app1class TestData(models.Model): field1 = models.CharField(max_length=200) field2 = models.CharField(max_length=200)class Knight(models.Model): name = models.CharField(max_length=100) additional_field_new_name = models.CharField(\ max_length=155, default='') data = models.ForeignKey(TestData)2. I've added new column data_new to Knight model with M2M relation to TestData:data_new = models.ManyToManyField(TestData, \ related_name='testdata_info')3. Start schema migration:python manage.py schemamigration app1 --auto4. Change forward method in our new migration, code after creation of new column/proxy model:for obj in orm.Knight.objects.all(): obj.data_new.add(obj.data) obj.save()5. Make migration:python manage.py migrate app16. Remove column data from model and make migration; rename m2m column data_new to data and start schema migration# remove column "data" from modelpython manage.py schemamigration app1 --autopython manage.py migrate app1# rename m2m column from "data_new" to "data"python manage.py schemamigration app1 --auto7. At this point I need to keep all existing data in proxy table but South won't do that for me. So, I need to change … -
An easy Django ForeignKey performance +1
Today, Christophe Pettus wrote about an easy way to get better database performance from a ForeignKey reference. Don’t do: pub_id = b.publisher.id Do do: pub_id = b.publisher_id After you read his post, you’ll think, “But of course!” Joe Bob says check it out. Tagged: Django -
Mailing list for Disqus open source projects
A couple of weeks ago we launched our engineering blog and project site where we aggregate our engineers’ blog posts and list open source projects we maintain. Since then, we released two more projects — feature switches platform called Gargoyle and a pluggable Django app called Nexus. And to... -
Feature Switches in Django with Gargoyle
-
Feature Switches in Django with Gargoyle
A while back we talked about using feature switches to deal with partial deployment. This allows you to easily deploy to portions of your audience, or bring out less finalized features without hiding them behind branches and the likes. This last week we hosted a company hack day here at DISQUS, a... -
Redirect to the originally requested page after django registration and email activation
For my newly-launched, django-based social shopping site Wantbox.com, I have implemented @ubernostrum‘s ubiquitous django-registration 0.7 to handle user registrations. Recently I completed a Wantbox feature that required me to redirect a new user back to their initially requested, authorization-required page after their registration and email activation. Below are the step-by-steps actions I took to accomplish this. Step One: Pass the “next” parameter from the login form to the registration form When a user requests a view adorned with the “@login_required()” decorator, Django automatically checks if that user “is_authenticated()” and redirects them to your login form if they are not. You’ll notice that there is a “?next=/foo/bar/” parameter tacked onto the end of the login page URL so you can send the use back to the requested page upon login. In my case, the user needs to register, not log in, so my first step was to pass this “next” parameter to the registration form. Under my login form I added this link: Not a member yet? <a href="{% url registration_register %}?next={{ request.REQUEST.next|urlencode }}">Sign up here</a> Step Two: Modify the registration form On your registration form, add a hidden input field to store the “next” parameter that you just passed in …