Skip to content

Instantly share code, notes, and snippets.

View vbmendes's full-sized avatar

Vinícius Mendes vbmendes

View GitHub Profile
@vbmendes
vbmendes / test_hash.py
Created March 11, 2012 03:38 — forked from rafaelcaricio/.gitignore
test_hash.py
#!/usr/bin/python
# -*- coding: utf-8 -*-
import json
cars = json.loads(open('./fixtures/fipe_carro.json').read())
tree = {}
for v in cars:
for name in v['translated_names']:
@vbmendes
vbmendes / group_users_form.py
Created February 1, 2012 02:19 — forked from rafaelnovello/group_users_form.py
Select users to the group in group form on Django Admin.
# -*- coding: utf-8 -*-
from django.forms import ModelForm
from django import forms
from django.contrib.auth.models import Group, User
class GroupAdminForm(ModelForm):
class Meta:
model = Group
group_users = forms.ModelMultipleChoiceField(label=u'Usuários deste Grupo', queryset=User.objects.all())
import os, uuid
from django.conf import settings
from django.db import models
from django.utils.encoding import smart_unicode, smart_str
class BannerFileField(models.FileField):
def pre_save(self, model_instance, add):
file = super(BannerFileField, self).pre_save(model_instance, add)
if not add: