Apologies, I seem to have misunderstood the situation in my haste to be of assistance. I admit I'm no Django/Python whiz, more of a talented(?) dabbler. Maybe someone else can correct me, but it seems that save() will always hit the entire row if you use a single model. Does save(f
It seems a bit hacky, but what about creating a method to parse the modelform's inner Meta.fields then generate and execute a custom UPDATE statement? This might be a bit more difficult if you're using exclude rather than fields. To keep it DRY attach this method to a subclass of modelform then make your existing modelforms subclasses of this. This seems like a lot more work than aught be necessary, so you may be best off waiting for someone more knowledgeable than me to chime in. On Wed, Oct 20, 2010 at 3:34 AM, simonty <si...@auspayroll.com.au> wrote: > I can't change the database design. Even if I could, that would still > mean I would have to define a model and a modelform for each table, > no? > > On Oct 20, 6:13 pm, srb...@gmail.com wrote: > > Can you just break the table up into several tables connected with > one-to-one relations? Maybe look at the model forms you're using the most as > a guide for which fields to include in the new tables? > > Sent from my Verizon Wireless BlackBerry > > > > -----Original Message----- > > From: simonty <si...@auspayroll.com.au> > > > > Sender: django-users@googlegroups.com > > Date: Tue, 19 Oct 2010 23:16:38 > > To: Django users<django-users@googlegroups.com> > > Reply-To: django-users@googlegroups.com > > Subject: DRY forms > > > > Hello, > > I have a database table with about 100 fields. > > I have a number of forms with only a few fields in each form based on > > the fields in the table. > > If I create one massive django model to represent the table and a > > number of modelforms based on > > the django model, this becomes inefficent because every time I update > > one of my small modelforms ( > > which contain only a few fields), all fields in the table will get > > updated. I can see this when I inspect the > > sql query. > > Alternatively I can create small django models and base my modelforms > > on those but this isn't very DRY. > > Its a alot of work. > > Ideally, when I call save() on my modelform, I only want the fields on > > my form to be updated. This makes sense because I am saving the > > information in the form, not the entire model. > > Could anyone make any suggestions for the above scenario? > > Many thanks. > > > > -- > > 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<django-users%2bunsubscr...@googlegroups.com> > . > > For more options, visit this group athttp:// > groups.google.com/group/django-users?hl=en. > > -- > 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<django-users%2bunsubscr...@googlegroups.com> > . > For more options, visit this group at > http://groups.google.com/group/django-users?hl=en. > > -- 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=en.