(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
from django.contrib.admin.models import LogEntry, CHANGE, ContentType | |
from reversion.revisions import default_revision_manager as revision_manager | |
from app.models import MyModel | |
revision_manager.register(MyModel) | |
LogUser, created = User.objects.get_or_create(username='LogUser') | |
if created: | |
ApplicationUser.first_name = 'Log' |
class MyForm(forms.Form): | |
# ... | |
def clean(self): | |
def set_field_error(field, message): | |
if field in self._errors: | |
self._errors[field].append(message) | |
else: | |
self._errors[field] = self.error_class([message]) | |
if field in cleaned_data.keys(): | |
del cleaned_data[field] |
class MyForm(forms.Form): | |
some_field = forms.CharField() | |
class MyWizard(SessionWizardView): | |
# ...do some stuff... | |
# And a url like: | |
url(r'^wizard/$', views.MyWizard.as_view([MyForm, MyOtherForm])) |
# -*- coding: utf-8 -*- | |
from functools import wraps | |
def memoize(obj): | |
""" | |
From Python Decorator Library | |
""" | |
cache = obj.cache = {} |
""" | |
Script to identify accounts followed older than 4 months. | |
Source blogpost: http://www.rainbowbreeze.it/identify-your-twitter-followings-older-that-4-months | |
""" | |
import tweetpony | |
from datetime import timedelta, datetime | |
import urllib3.contrib.pyopenssl | |
import time |
# -*- coding: utf-8 -*- | |
from __future__ import absolute_import | |
from django.conf import settings | |
from haystack.backends.elasticsearch_backend import ( | |
ElasticsearchSearchBackend, ElasticsearchSearchEngine, ElasticsearchSearchQuery) | |
from haystack.query import SearchQuerySet | |
import __builtin__ | |
original_import = __builtin__.__import__ | |
def log_import(name, globals={}, locals={}, fromlist=[], level=-1): | |
print name | |
return original_import(name, globals=globals, locals=locals, fromlist=fromlist, level=level) | |
__builtin__.__import__ = log_import |
import haystack | |
from django.core.management import call_command | |
from django.test.utils import override_settings | |
TEST_INDEX = { | |
'default': { | |
'ENGINE': 'haystack.backends.elasticsearch_backend.ElasticsearchSearchEngine', | |
'URL': 'http://127.0.0.1:9200/', |
(by @andrestaltz)
If you prefer to watch video tutorials with live-coding, then check out this series I recorded with the same contents as in this article: Egghead.io - Introduction to Reactive Programming.
# -*- coding: utf-8 -*- | |
""" | |
Search features for an elasticsearch / haystack / elasticstack | |
:creationdate: 05/11/15 15:05 | |
:moduleauthor: François GUÉRIN <[email protected]> | |
:modulename: intrautils.search | |
""" | |
import base64 |