471,354 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,354 software developers and data experts.

what is the difference between get() and filter() function?

hi

i am quite confused between get() function and filter() function, what is the difference between. it seems they all retrieve the specific row from database.
i have written this code in one function of my application and it works:
Expand|Select|Wrap|Line Numbers
  1.  
  2.     Rt=outlet.objects.get(id__exact=return_location)
  3.     r=Rt.outlet_name
  4.  

in my other functions, i write this and it also works:
Expand|Select|Wrap|Line Numbers
  1.      allObj =Booking1.objects.filter(id = booking)
  2.  
in the other scenario, which i use filter it will work but when i change it into get,it complain about errors. which the code is like the following:
Expand|Select|Wrap|Line Numbers
  1.             my = Booking1.objects.filter(id__exact= myId)    
  2.             my.delete()
  3.  
thus i am very confused about how it works and what is the difference between get() and filter()

(PS, i am using Django framework which is build on python programming language)

this problem is a bit urgent at the moment,as it causes a lot of problem for me and my project is running out of time. thanks in advance for any kind help :)
Dec 19 '07 #1
0 802

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

26 posts views Thread by Steven Bethard | last post: by
669 posts views Thread by Xah Lee | last post: by
16 posts views Thread by nephish | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.