Re: Shortcut to create and update a model object?

2009-11-23 Thread Daniel Roseman
On Nov 20, 8:31 am, "Boris Schaeling"  wrote:
> Is there a shortcut to create and update a model object from a form? For  
> example I'd like to write something like:
>
> MyModel.objects.create(mymodel_form.cleaned_data)
>
> or
>
> model_obj = get_object_or_404(MyModel, pk=id)
> model_obj.update(mymodel_form.cleaned_data)
>
> Not setting attributes individually would also make it easier to change  
> models later without adding or removing attributes in the views.
>
> Boris

Use a ModelForm.
--
DR.

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.




Shortcut to create and update a model object?

2009-11-22 Thread Boris Schaeling
Is there a shortcut to create and update a model object from a form? For  
example I'd like to write something like:

MyModel.objects.create(mymodel_form.cleaned_data)

or

model_obj = get_object_or_404(MyModel, pk=id)
model_obj.update(mymodel_form.cleaned_data)

Not setting attributes individually would also make it easier to change  
models later without adding or removing attributes in the views.

Boris

--

You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-us...@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=.