How about:
def filter_keys(hash, keys):
# I'm convinced there must be a better way to write this
return dict([ item for item in hash.iteritems() if item[0] in
keys ])
def save(self):
Blog.objects.create(**filter_keys(self.clean_data, ['name',
'description'])
Although I can often omit
Actually no :-(
It will conflict with keys, clear etc members of standard dictionary. May be
I will write a MyForm that will do it locally for me, from which I will
inherit the rest of my forms.
On 3/7/07, Amit Upadhyay <[EMAIL PROTECTED]> wrote:
>
> Hi,
>
> I have an enhancement request for new
Hi,
I have an enhancement request for new forms, instead of doing
def save(self):
> Blog.objects.create(title=self.clean_data["title"], description=
> self.clean_data["description"])
>
and
def __init__(self, blog, *args, **kw):
> super(MyForm, self).__init__(*args, **kw)
> self.fields["title"].