-
Install and register the FreeTDS driver for unixODBC.
apt-get install tdsodbc odbcinst -i -d -f /usr/share/tdsodbc/odbcinst.ini
-
(Optional) Test the DSN-less connection with pyodbc.
apt-get install python-pyodbc
>>> import pyodbc
#!/usr/bin/env python | |
""" | |
Obviously this is only useful if you have to deal with Django's | |
Trac a lot. | |
Mostly stolen from Jacob Kaplan-Moss, but improved by Jannis Leidel | |
and Aymeric Augustin. | |
Reads a config file at ~/.djpatchrc, e.g.: |
from django.contrib import admin | |
class ReadOnlyModelAdmin(admin.ModelAdmin): | |
""" | |
ModelAdmin class that prevents modifications through the admin. | |
The changelist and the detail view work, but a 403 is returned | |
if one actually tries to edit an object. |
import datetime | |
import hashlib | |
from django.views.decorators.cache import cache_page | |
from django.views.decorators.http import condition | |
from django.views.i18n import javascript_catalog | |
def get_version(): | |
# Write your own! That depends on your deployment strategy. | |
# This example won't work if you release more than once a day. |
import logging | |
logger = logging.getLogger('django.db.backends') | |
logger.setLevel(logging.DEBUG) | |
logger.addHandler(logging.StreamHandler()) |
"""Convert datetimes in the database when switching USE_TZ from False to True. | |
tl;dr RUNNING THIS SCRIPT CAN RESULT IN DATA CORRUPTION, DATA LOSS AND EVEN | |
SERVER CRASHES. USE IT AT YOUR OWN RISK. NO WARRANTY WHATSOEVER. | |
This is a management command. Put it in the management.commands package of | |
one of your applications, then run: ./manage.py convert_to_utc <app_name> ... | |
This script assumes that no write operations take place while it's running. | |
It will rewrite every single record in your database; that's its whole point. |
from optparse import make_option | |
from django.test.simple import DjangoTestSuiteRunner | |
def fake_create_test_db(self, verbosity=1, autoclobber=False): | |
"""Simplified version of BaseDatabaseCreation.create_test_db.""" | |
test_database_name = self._get_test_db_name() | |
if verbosity >= 1: |
from cms.models import Title | |
from django.contrib.redirects.models import Redirect | |
titles_with_redirect = Title.objects.exclude(redirect__isnull=True).exclude(redirect=u'') | |
for title in titles_with_redirect.select_related('page__site'): | |
Redirect.objects.create( | |
site=title.page.site, | |
old_path=u'/%s/' % title.path, | |
new_path=title.redirect, |
"""Build a mapping between svn commits and git changesets. | |
Usage: python build_svn_to_git_mapping.py > svn_to_git.py | |
This script should be run in a clone of the git repository, | |
with a checkout of https://code.djangoproject.com/svn/django in ../django-svn. | |
""" | |
import os | |
import pprint |
Install and register the FreeTDS driver for unixODBC.
apt-get install tdsodbc
odbcinst -i -d -f /usr/share/tdsodbc/odbcinst.ini
(Optional) Test the DSN-less connection with pyodbc.
apt-get install python-pyodbc
>>> import pyodbc