Skip to content

Instantly share code, notes, and snippets.

@george-silva
Created April 12, 2013 15:19
Show Gist options
  • Save george-silva/5372806 to your computer and use it in GitHub Desktop.
Save george-silva/5372806 to your computer and use it in GitHub Desktop.
foda
class FormFoda(forms.ModelForm):
def __init__(self, usuario, campo, *args, **kwargs):
self.usuario = usuario
self.campo = campo
super(FormFoda, self).__init__(*args,**kwargs )
def save(self, commit=True):
if hasattr(self.instance, self.campo):
setattr(self.instance, self.campo, self.usuario)
return super(FormFoda, self).save(commit)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment