I hereby claim:
- I am gtsalles on github.
- I am gtcarvalho (https://keybase.io/gtcarvalho) on keybase.
- I have a public key ASAEqSRvP0zECfNlvIqJmbNBkl25rAoApzDF1PCMShxt8Ao
To claim this, I am signing this object:
I hereby claim:
To claim this, I am signing this object:
def get_form(self, request, obj=None, **kwargs): | |
if obj: | |
self.readonly_fields = ('employer',) | |
else: | |
self.readonly_fields = () | |
return super(ScoreAdmin, self).get_form(request, obj, **kwargs) |
Verifying that +gtcarvalho is my blockchain ID. https://onename.com/gtcarvalho |
#alfabeto = range(97,(97+26)) | |
letra = raw_input("Insira o caractere: ") | |
i = ord(letra) - 65 | |
aux = 0 | |
for j in range(i, -1, -1): | |
if aux == 0: | |
print "%s%c"%(' '*j, chr(65)) | |
else: | |
print "%s%c%s%c"%(' '*j, chr(65+aux),' '*((aux-1)*2+1),chr(65+aux)) | |
aux += 1 |
def get_changelist(self, request, **kwargs): | |
cl = super(CurriculoAdmin, self).get_changelist(request, **kwargs) | |
class CustomCL(cl): | |
def get_queryset(self, *args, **kwargs): | |
qs = super(CustomCL, self).get_queryset(*args, **kwargs) | |
# deveria montar a query baseadas nos parametros get que passei e | |
# retornar o novo queryset mas não consigo pegar os parâmetros do get | |
return qs.filter(query) | |
from django.db.models.signals import pre_save, post_save, post_delete | |
from django.dispatch import receiver | |
class RandomModel(models.Model): | |
"""fields, etc, etc""" | |
# Esse método vai ser executado antes de salvar o model RandomModel (model que tá no sender aqui abaixo) | |
@receiver(pre_save, sender=RandomModel) | |
def random_pre_save(instance, **kwargs): |
# -*- coding: utf-8 -*- | |
texto = 'Um pequeno jabuti xereta viu dez cegonhas felizes.' | |
limite = 20 | |
cont_espacos = 0 | |
while len(texto) >20: | |
print "Tamanho String: ", len(texto) | |
if texto[19] != ' ': |
def formfield_for_foreignkey(self, db_field, request, **kwargs): | |
if db_field.name == "usuario": | |
usuario_id = request.GET.get('usuario_id', None) | |
if usuario_id: | |
kwargs['initial'] = usuario_id | |
if db_field.name == "psicologo": | |
kwargs["queryset"] = User.objects.filter(is_superuser=True) | |
return super(EntrevistaAdmin, self).formfield_for_foreignkey(db_field, request, **kwargs) |