Re: Solution: change only a subset of a model's field in newforms

2007-02-28 Thread anders conbere

On 2/28/07, Joseph Kocherhans <[EMAIL PROTECTED]> wrote:
>
> On 2/28/07, akaihola <[EMAIL PROTECTED]> wrote:
> >
> > It must be a common need to allow the user to change only some fields
> > of an object and keep old values for the rest.
> >
> > So far with newforms this has involved copying values explicitly from
> > the database object to the form object. Looking at newforms code I
> > realized that a cleaner way is to just not try to copy missing fields
> > from the form object to the database object before saving.
> >

Similarly from a non-autogenerator standpoint there is currently no
method for taking data in an instance of an object and passing that to
the form for initialization.  The best we could come up with that
using object_instance.__dict__ and then feeding in by hand foreign
fields and manyToMany fields.

Perhaps what we need is really a more abstracted function that would
allow for similar syntax to what was proposed but works independant of
the auto-generator functions.

something like a object_instance.values(include = ('content',))

which could then be utilized by the autogenerators to provide that
same functionality while offering to those of us who don't fit the
auto-gen mold, to be able to have similar functionality.

~ Anders

> > For one possible solution, see 
> > http://akaihola.blogspot.com/2007/02/django-newforms-improvement.html
> > for details and the code.
> >
> > The code is based on newforms.models and makes minimal changes to
> > form_for_instance (and its helper functions) to achieve the new
> > functionality.
> >
> > If this new behaviour doesn't violate the intentions behind newforms,
> > could it be adapted into Django?
>
> I've written similar code, and that functionality definitely belongs
> in Django. The best way to get it considered for inclusion is to file
> a patch with docs and tests. You may want to propose the syntax on
> django-developers first, however.
>
> http://www.djangoproject.com/documentation/contributing/#submitting-patches
>
> Joseph
>
> >
>

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Re: Solution: change only a subset of a model's field in newforms

2007-02-28 Thread Joseph Kocherhans

On 2/28/07, akaihola <[EMAIL PROTECTED]> wrote:
>
> It must be a common need to allow the user to change only some fields
> of an object and keep old values for the rest.
>
> So far with newforms this has involved copying values explicitly from
> the database object to the form object. Looking at newforms code I
> realized that a cleaner way is to just not try to copy missing fields
> from the form object to the database object before saving.
>
> For one possible solution, see 
> http://akaihola.blogspot.com/2007/02/django-newforms-improvement.html
> for details and the code.
>
> The code is based on newforms.models and makes minimal changes to
> form_for_instance (and its helper functions) to achieve the new
> functionality.
>
> If this new behaviour doesn't violate the intentions behind newforms,
> could it be adapted into Django?

I've written similar code, and that functionality definitely belongs
in Django. The best way to get it considered for inclusion is to file
a patch with docs and tests. You may want to propose the syntax on
django-developers first, however.

http://www.djangoproject.com/documentation/contributing/#submitting-patches

Joseph

--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---



Solution: change only a subset of a model's field in newforms

2007-02-28 Thread akaihola

It must be a common need to allow the user to change only some fields
of an object and keep old values for the rest.

So far with newforms this has involved copying values explicitly from
the database object to the form object. Looking at newforms code I
realized that a cleaner way is to just not try to copy missing fields
from the form object to the database object before saving.

For one possible solution, see 
http://akaihola.blogspot.com/2007/02/django-newforms-improvement.html
for details and the code.

The code is based on newforms.models and makes minimal changes to
form_for_instance (and its helper functions) to achieve the new
functionality.

If this new behaviour doesn't violate the intentions behind newforms,
could it be adapted into Django?


--~--~-~--~~~---~--~~
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
-~--~~~~--~~--~--~---