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 Container(models.Model): | |
children = models.OneToManyField(Child) #I know this one to many field does not exist | |
class Child(models.Model): | |
random_field = models.IntegerField(default=1) | |
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.auth.models import User | |
from django.shortcuts import get_object_or_404 | |
#this view would be publicly accessable | |
def hook(request, username=None): | |
user = get_object_or_404(User, username=username) #cant remember the syntax | |
if not isinstance(User, user): | |
return user #this returns a 404 | |
#now we know what user we are dealing with |
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.models import Model | |
from django.auth.models import User | |
class Achievement(Model): | |
user = models.foreignKey(User) | |
created_at = models.DateTimeField() | |
def fetch_achievement(self): | |
#do some achievement logic in here |
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
# http://henrik.nyh.se/2008/12/git-dirty-prompt | |
# http://www.simplisticcomplexity.com/2008/03/13/show-your-git-branch-name-in-your-prompt/ | |
# username@Machine ~/dev/dir[master]$ # clean working directory | |
# username@Machine ~/dev/dir[master*]$ # dirty working directory | |
function parse_git_dirty { | |
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*" | |
} | |
function parse_git_branch { | |
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/" |
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 override_urls(self): | |
return [ | |
url(r'^offer/(?P<offer_id>\d+)/(?P<resource_name>%s)/(?P<offer_transaction_id>\d+)/$' % self._meta.resource_name, self.wrap_view('get_offer_transaction_id'), name="api_get_offer_transaction_id"), | |
url(r'^offer/(?P<offer_id>\d+)/(?P<resource_name>%s)/$' % self._meta.resource_name, self.wrap_view('get_offer_transaction'), name="api_get_offer_transaction"), | |
] |
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
patterns = [ | |
(r'^(?P<resource_name>offer)/(?P<pk_list>\w[\w/;-]*)/$', someview), | |
(r'^offer/(?P<offer_id>\d+)/(?P<resource_name>transaction)/$', someotherview), | |
(r'^offer/(?P<offer_id>\d+)/(?P<resource_name>transaction)/(?P<offer_transaction_id>\d+)/$', someview), | |
] | |
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
" Vim syntax file | |
" Language: Django template | |
" Maintainer: Dave Hodder <dmh@dmh.org.uk> | |
" Last Change: 2010 May 19 | |
" For version 5.x: Clear all syntax items | |
" For version 6.x: Quit when a syntax file was already loaded | |
if version < 600 | |
syntax clear | |
elseif exists("b:current_syntax") |
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
mkdir ~/virtualenvs |
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
if settings.DEBUG: | |
urlpatterns += patterns("", | |
(r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT, 'show_indexes':True}),) |
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
#first generate a key for your domain | |
openssl genrsa -out yourdomain.com.key 2048 | |
#then generate the request | |
openssl req -new -key yourdomain.com.key -out yourdomain.com.csr |