This file contains hidden or 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 AdminInscricao(ProjectModelAdmin): | |
| list_display = ('email', 'nome', 'inscrito', 'admin_grupos', 'data_de_criacao', ) | |
| search_fields = ('email', 'nome') | |
| list_filter = ('inscrito', 'grupos') | |
| actions = ('subscribe_action', 'unsubscribe_action') | |
| def admin_grupos(self, obj): |
This file contains hidden or 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 MyForm(forms.ModelForm): | |
| ... | |
| def __init__(self, *args, **kwargs): | |
| self.competition = kwargs.pop('competition') | |
| super(MyForm, self).__init__(*args, **kwargs) | |
| def clean(self): | |
| """ Use self.competition here """ |
This file contains hidden or 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 NomeDoForm(forms.ModelForm): | |
| class Meta: | |
| model = NomeDoModel | |
| def __init__(self, *args, **kwargs): | |
| super(NomeDoForm, self).__init__(*args, **kwargs) | |
| self.fields['nome_do_campo'].widget.attrs['class'] = 'mceClass' |
This file contains hidden or 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 MyModelAdmin(ModelAdmin): | |
| ... | |
| def __getattr__(self, name): | |
| """ | |
| Permite o uso de um atributo no admin com o nome | |
| do atributo mais '_or_blank'. Exemplo: name_or_blank | |
| """ | |
| if name.endswith('_or_blank'): | |
| try: | |
| return getattr(self, name[:-9]) or u'' |
This file contains hidden or 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
| # -*- coding: utf8 -*- | |
| """ | |
| Você pode criar a mensagem no próprio form. | |
| """ | |
| from django import forms | |
| from django.forms.util import ErrorList | |
| from models import UserDoc |
This file contains hidden or 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 | |
| # -*- coding: utf-8 -*- | |
| class HTTPRequest(object): | |
| """ | |
| Class to generate plain HTTP Requests | |
| usage: | |
| >>> req = HTTPRequest('meiocodigo.com', path='/') | |
| >>> req.add_header('Content-Type', 'application/x-www-form-urlencoded') |
This file contains hidden or 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.template import Node, TemplateSyntaxError | |
| from django.template import resolve_variable | |
| from django.utils.encoding import smart_str | |
| class BaseNode(Node): | |
| def __init__(self, **kwargs): | |
| self.parsed = kwargs | |
This file contains hidden or 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 models import Pais | |
| class MyForm(forms.Form): | |
| pais = forms.ModelChoiceField(queryset = Pais.objects.all()) | |
| def __init__(self, *args, **kwargs): |
This file contains hidden or 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
| source /usr/local/Cellar/git/1.7.5.4/etc/bash_completion.d/git-completion.bash # path to git completion | |
| export GIT_PS1_SHOWDIRTYSTATE=1 | |
| export GIT_PS1_SHOWSTASHSTATE=1 | |
| export GIT_PS1_SHOWUNTRACKEDFILES=1 | |
| export GIT_PS1_SHOWUPSTREAM="verbose" | |
| PS1='\[$(tput setf 3)\]\u\[$(tput sgr0)\]: \[$(tput setf 6)\]\w \[$(tput setf 2)\]$(__git_ps1 "(%s)")\n\[$(tput bold)$(tput setf 6)\]$ \[$(tput sgr0)\]' | |
| source ~/.bashrc |