Re: Update database field
Hi, This is what i ended up doing in a project of mine.But this involved two DB calls One to retrieve and another to save, but with just SQL can be accomplished in a single UPDATE statement. Django docs menthion that if you explicitly specify an id (primary key ) it should update the db. So I did something like this i = Item.(id=4, name='New Name') i.save() The Item model has a created_at column, which is sent NULL if I do this. Hence the query fails. There shoud be a better way of doing it. -- Manu On 11/14/06, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > Yea, that will work. > > Get the "thing" > change the value > store it. > > > tinti wrote: > > Got it: > > > > update = Queue.objects.get(message=message_id) > > update.read = 1 > > update.save() > > > > I thinks this is the correct way, if not somebody can advise me another > > ;) > > > > On Nov 14, 11:37 am, "tinti" <[EMAIL PROTECTED]> wrote: > > > Hi all, > > > I need some help updating a database field. Can someone post me an > > > example on updating a database field using the views.py and a static > > > value to update. For example each time an item is requested set the > > > field read to 1. I have to build something similar. > > > > > > Thanks for any reply > > > > > > tinti > > > > > --~--~-~--~~~---~--~~ 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: Update database field
Yea, that will work. Get the "thing" change the value store it. tinti wrote: > Got it: > > update = Queue.objects.get(message=message_id) > update.read = 1 > update.save() > > I thinks this is the correct way, if not somebody can advise me another > ;) > > On Nov 14, 11:37 am, "tinti" <[EMAIL PROTECTED]> wrote: > > Hi all, > > I need some help updating a database field. Can someone post me an > > example on updating a database field using the views.py and a static > > value to update. For example each time an item is requested set the > > field read to 1. I have to build something similar. > > > > Thanks for any reply > > > > tinti --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---
Update database field
Hi all, I need some help updating a database field. Can someone post me an example on updating a database field using the views.py and a static value to update. For example each time an item is requested set the field read to 1. I have to build something similar. Thanks for any reply tinti --~--~-~--~~~---~--~~ 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: Update database field
Got it: update = Queue.objects.get(message=message_id) update.read = 1 update.save() I thinks this is the correct way, if not somebody can advise me another ;) On Nov 14, 11:37 am, "tinti" <[EMAIL PROTECTED]> wrote: > Hi all, > I need some help updating a database field. Can someone post me an > example on updating a database field using the views.py and a static > value to update. For example each time an item is requested set the > field read to 1. I have to build something similar. > > Thanks for any reply > > tinti --~--~-~--~~~---~--~~ 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 -~--~~~~--~~--~--~---