On Sep 9, 7:10 am, Jim Myers <myer...@gmail.com> wrote: > I have a database model with many fields, some of which I don't want > displayed in a form and others I don't want to be editable. Is it > possible to do this with a ModelForm? Or is it even possible with > regular forms? > > Furthermore, I only want the SQL update statement to update ONLY the > fields actually displayed in the form (only the editable ones). I > know it can do it if I write my own SQL but does Django provide a way? > > I've read most of the available docs and a lot of stuff on Google and > still don't see how to do these things. > > Any help/insight will be appreciated!
If you want fields not to display on a form, use the exclude attribute when defining the modelform - see http://docs.djangoproject.com/en/dev/topics/forms/modelforms/#using-a-subset-of-fields-on-the-form There isn't a built-in way to have fields display but not be editable, but you could easily use one of the read-only widgets available on djangosnippets.org, or simply display them individually in your template. As regards updating, Django will only update the fields that have changed in any case. -- 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-users@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=en -~----------~----~----~----~------~----~------~--~---