* giovedì 08 febbraio 2007, alle 07:17, Russell Keith-Magee wrote :
> Ok - this is saving a form created from a model. Since your model
> contains a m2m field, the form representing that model will have an
> m2m widget, and when you save() the form, the m2m relation on the
> object will be modified.

ok ... first of all TANKS for the help and for the very clear explanation
;-)))

I've resolved (more clear and more coincise !!) with:

*******
def previsione(req, varid=None):
        if req.method == 'POST':
                myform = nf.models.form_for_model(Prev)(req.POST)

                if myform.is_valid():
                        if varid is not None:
                                instance = get_object_or_404(Prev, pk=varid)
                                newforms.models.save_instance(myform, instance)
                        else:
                                myform.save()

                        clean_path=re.sub('/[0-9]+/','',req.path)

                        return HttpResponseRedirect(clean_path)
        else:
        ....
********

the last thing is that the m2m data are ALWAYS updated with an increment of
the 'id', even if data are unchanged ... but I think I've to "play"
(eventually ;-))) with the 'save()' method ...

tanks again .... my turn next time ... I hope ;-)))

bye ....

-- 
#include <stdio.h>
int main(void){char c[]={10,65,110,116,111,110,105,111,32,98,97,114,98,111,110,
101,32,60,104,105,110,100,101,109,105,116,64,116,105,115,99,97,108,105,110,101,
116,46,105,116,62,10,10,0};printf("%s",c);return 0;}

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

Reply via email to