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 mediagenerator.settings import DEV_MEDIA_URL, MEDIA_DEV_MODE | |
# Only load other dependencies if they're needed | |
if MEDIA_DEV_MODE: | |
from mediagenerator.utils import _refresh_dev_names, _backend_mapping | |
from django.http import HttpResponse, Http404 | |
from django.utils.cache import patch_cache_control | |
from django.utils.http import http_date | |
import time |
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 import forms | |
class PlaceholderForm(forms.ModelForm): | |
def __init__(self, *args, **kwargs): | |
super(PlaceholderForm, self).__init__(*args, **kwargs) | |
for field in self.fields.values(): | |
new_attrs = { | |
'placeholder': field.label |
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
import os | |
import sys | |
INTERP = os.path.join(os.environ['HOME'], '.virtualenvs', 'project', 'bin', 'python') | |
if sys.executable != INTERP: | |
os.execl(INTERP, INTERP, *sys.argv) | |
sys.path.insert(1, os.getcwd()) # '[...]./' | |
sys.path.insert(1, os.path.join(os.getcwd(), 'project')) # '[...]/project/' |
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
python -c 'from django.utils.crypto import get_random_string; print "\nSECRET_KEY = \"%s\"\n" % get_random_string(50, "abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)")' |
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
# Sublime Features | |
SublimeLinter | |
ColorPicker | |
Package Control | |
# Html | |
HTMLAttributes | |
HtmlTidy | |
# JavaScript |
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
# I have not tested, only didactic. | |
# | |
# signals.py | |
# | |
from django.core.mail import EmailMultiAlternatives | |
from django.template.loader import render_to_string | |
def send_notification_mail(sender, instance, raw, using): | |
context = {} |
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
class SubdomainURLRoutingMiddleware(SubdomainMiddleware): | |
def process_request(self, request): | |
super(SubdomainURLRoutingMiddleware, self).process_request(request) | |
subdomain = getattr(request, 'subdomain', False) | |
if subdomain is not False and subdomain not in settings.SUBDOMAIN_BLACKLIST: | |
# Here is the trick. I will put at the first rule the users url | |
# set at the settings, this way, the first page will be the | |
# user page matched with subdomain. |
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
# Nginx | |
server { | |
# [...] | |
server_name *.yourdomain.com; | |
# [...] | |
} |
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.conf import settings | |
from django.conf.urls import patterns, include, url | |
from django.contrib.staticfiles.urls import staticfiles_urlpatterns | |
# from django.contrib import admin | |
# admin.autodiscover() | |
urlpatterns = patterns('', | |
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')), |
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
import os | |
# Project information | |
PROJECT_PATH = os.path.realpath(os.path.dirname(__file__)) | |
PROJECT_NAME = os.path.basename(PROJECT_PATH) | |
# Helpers | |
path = lambda *p: os.path.join(PROJECT_PATH, *p) | |
# Debug |