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 random | |
class MasterSlaveRouter(object): | |
def db_for_read(self, model, **hints): | |
""" | |
Reads go to a randomly-chosen slave. | |
""" | |
return random.choice(['master','slave1', 'slave2']) | |
def db_for_write(self, model, **hints): |
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
DATABASES = { | |
'default': { | |
'ENGINE': 'django.db.backends.mysql', | |
'NAME': 'anotherdatabase', | |
'USER': 'anotherusername', | |
'PASSWORD': 'anotherpassword', | |
'HOST': '192.168.1.1', | |
'PORT': '', | |
}, | |
'master': { |
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 random | |
class MasterSlaveRouter(object): | |
def db_for_read(self, model, **hints): | |
""" | |
Reads go to a randomly-chosen slave. | |
""" | |
return random.choice(['master','slave1', 'slave2']) | |
def db_for_write(self, model, **hints): |
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
#!/usr/bin/env python | |
"""MailBox class for processing IMAP email. | |
(To use with Gmail: enable IMAP access in your Google account settings) | |
usage with GMail: | |
import mailbox | |
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 models | |
from django.contrib.auth.models import User | |
class Person(models.Model): | |
employee_id = models.IntegerField(unique=True,editable=False) | |
username = models.CharField(max_length=50,unique=True,editable=False) | |
state_id = models.IntegerField(unique=True,null=True,blank=True,editable=False) | |
email = models.EmailField(max_length=50,unique=True,editable=False) | |
firstname = models.CharField(max_length=50,editable=False) | |
lastname = models.CharField(max_length=50,editable=False) |
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 __unicode__(self): | |
if self.name: | |
return u'%s' % (self.name) | |
elif self.assettag: | |
return u'%s' % (self.assettag) | |
elif self.mac_wired: | |
return u'%s' % (self.mac_wired) | |
elif self.model.chassis: | |
return u'%s' % (self.model.chassis) | |
else: |
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 | |
from inventory.models import Computer | |
class ComputerForm(forms.ModelForm): | |
class Meta: | |
model = Computer | |
class ChromebookForm(forms.ModelForm): |
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.urls import patterns, include, url | |
from chordcharts.views import ChordListView #for class based views | |
from chordcharts import views #for function based views | |
urlpatterns = patterns('', | |
url(r'^$', ChordListView.as_view(), name='chord_list'), #for class based views | |
url(r'^$', 'chordcharts.views.chord_list', name='chord_list'), #for function based views | |
url(r'^chordcharts/', include('chordcharts.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
global | |
log 127.0.0.1 local0 notice | |
maxconn 20000 | |
user haproxy | |
group haproxy | |
defaults | |
log global | |
mode tcp | |
option dontlognull |
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
{% for i in '123'|make_list %} | |
{% if object.property == i|add:"0" %} | |
<li>(Selected) Property {{ i }}</li> | |
{% else %} | |
<li>Property {{ i }}<li> | |
{% endif %} | |
{% endfor %} |
OlderNewer