sudo apt-get update
sudo apt-get upgrade
sudo apt-get install python-virtualenv
sudo virtualenv /opt/myenv
from django import forms | |
from django.contrib.auth.models import User | |
class UserProfileForm(forms.ModelForm): | |
class Meta: | |
model = User | |
fields = ['first_name', 'last_name', 'email'] | |
I just had to set up Jenkins to use GitHub. My notes (to myself, mostly):
For setting up Jenkins to build GitHub projects. This assumes some ability to manage Jenkins, use the command line, set up a utility LDAP account, etc. Please share or improve this Gist as needed.
smtp_host = smtp.mailgun.org
smtp_starttls = False
smtp_ssl = True
smtp_user = USERNAME
smtp_port = 465
smtp_password = PASSWORD
smtp_mail_from = EMAIL
You can override the runserver command (or other management commands and make your own. Django 1.8 doesn't use optparse anymore but I rather like it's parser. This is a quick extension of the runserver command to set an env variable which will disable reCAPTCHA fields.
someapp/profile/management/commands/runserver.py
:
from django.contrib.staticfiles.management.commands import runserver import os
As per this django-invitations issue, django-invitations considers an invite "accepted" if the invite link is clicked. This is problematic for two reasons (or more):
Something to consider is that this solution assumes you're using django-allauth as it uses the EmailAddress
model of that package.
import datetime | |
import itertools | |
# it generates dates in 30 minutes intervals | |
date_generator = (datetime.datetime.today() - datetime.timedelta(minutes=i) for i in itertools.count(0, 30)) | |
# it gets 24h of data | |
dates = itertools.islice(date_generator, 24 * 2) | |
# convert generator data in list |
# Keeping Dictionaries in Order | |
from collections import OrderedDict | |
d = OrderedDict() | |
d['foo'] = 1 | |
d['bar'] = 2 | |
d['spam'] = 3 | |
d['grok'] = 4 | |
# Outputs "foo 1", "bar 2", "spam 3", "grok 4" |