This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Options +ExecCGI | |
AddHandler cgi-script .cgi | |
RewriteEngine On | |
RewriteBase / | |
RewriteCond %{REQUEST_FILENAME} !-f | |
RewriteRule ^(.*)$ django.cgi/$1 [QSA,L] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db import transaction | |
from django.db.models import Model | |
from django.contrib.contenttypes.generic import GenericForeignKey | |
from django.apps import apps | |
@transaction.atomic | |
def merge_model_objects(primary_object, alias_objects=[], keep_old=False): | |
""" | |
Use this function to merge model objects (i.e. Users, Organizations, Polls, | |
etc.) and migrate all of the related fields from the alias objects to the |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
username: vagrant | |
password: vagrant | |
sudo apt-get update | |
sudo apt-get install build-essential zlib1g-dev git-core sqlite3 libsqlite3-dev | |
sudo aptitude install mysql-server mysql-client | |
sudo nano /etc/mysql/my.cnf |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def GenericCSVExport(qs, fields=None): | |
from django.db.models.loading import get_model | |
from django.http import HttpResponse, HttpResponseForbidden | |
from django.template.defaultfilters import slugify | |
import csv | |
model = qs.model | |
response = HttpResponse(mimetype='text/csv') | |
response['Content-Disposition'] = 'attachment; filename=%s.csv' % slugify(model.__name__) | |
writer = csv.writer(response) |