and ofcourse that should be: b.save() and not without the ()s On Wed, Dec 16, 2009 at 5:40 PM, Itay Donenhirsch <[email protected]> wrote: > try: > b = Att.objects.get( pk = whatever_you_like ) > b.fieldname = a_variable > b.save > except Att.DoesNotExist: > print "oy vey" > > you could also replace b.fieldname = ... with: > b.__setattr__( 'fieldname', a_variable ) > > itay > > On Wed, Dec 16, 2009 at 5:35 PM, rmschne <[email protected]> wrote: >> Am I missing something? I want to be able to update just one field in >> one records of a database via the Django data model. If I create an >> object for that record and update that one field, via >> >> b=Att(fieldname=a_variable) >> b.save >> >> It creates a new record with all other fields blank. For simplicity >> (and scalability of code), I'd prefer not to create a new record, nor >> do I want to put in all the field names. >> >> I undestand how I could (but have not yet done this) write custom SQL >> to do this; but is there a way using the native Django method of >> updating existing database? >> >> -- >> >> You received this message because you are subscribed to the Google Groups >> "Django users" group. >> To post to this group, send email to [email protected]. >> 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. >> >> >> >
-- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to [email protected]. 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.

