views:

28

answers:

1

hi,

un rails i can simply insert the params into the database with one command, when all form-field names are the same like the model-field names. is this possible in django as well, or do i have to set each param individually. i have like 20 fields, so it's a bit of a mess.. :)

something like:

blah = Contact()
blah.content = params[]
blah.save()

thanks!

+2  A: 

Well, if you're using a form, you should use a ModelForm, so you can do form.save().

But generally, you can instantiate an object from a dictionary of parameters using the **kwargs format:

blah = Contact(**params)
Daniel Roseman
modelform, perfect! thank you
Tronic