All hail, Django models. 14

Posted by Peter Morris Tue, 29 Dec 2009 11:27:00 GMT

I have been spending a lot of time writing Django code (as you have probably noticed). In the past, I have been quite derisory about Django, there are many things that I don't like. Djangos ORM is NOT one of the problems. Well, fundamentally, it isn't. On the surface it stinks. So, lets get the nasty out of the way first. Some examples. In Rails, how do I find a particular instance if I know the ID? instance = Model.find(123) in Django instance = Model.objects.get(pk=123) Thats UGLY. This whole idea of managers, is a nice idea, but it is not entirely pretty. Now for the good thing. in Ruby if you do... object_list = Model.find(:all) you will get a big array filled with instances of all the objects in the database. Needless to say, this can SWALLOW your system. So, you have to be careful with AcriveRecord::Base, you get what you ask for, and if you ask for the moon, your system will fall to its knees and die. in Django if you do.... object_list = Model.objects.all() You will get an object that pretends to be an array, and only when you access chunks of it will it actually go over to the DB and pull back the required information. Thats NICE. BUT, it means you have to be a bit more careful, as it lulls you into a false sense of security. You have to remember that if you DO ask for the list of objects, you WILL get them. So, you have to remember. In rails, you know up front that you have to be careful, so its not quite as nice, but you aren't coddled. So, I do like Django models, it works in a more scalable fashion than Rails' ActiveRecord:Base. This leads me down the road of drawing comparisons between Ruby and Python. But thats the subject of a whole nother post.
  1. qdbietl about 1 month later:
  2. audio about 1 month later:
    home insurance =-) cheap auto insurance %]]] auto insurance iskvw
  3. anderson about 1 month later:
    health insurance llo auto insurance 330 auto insurance 8774 automobile insurance rifk
  4. jordy about 1 month later:
    health insurance for individuals 804551 cheap life insurance >:-((( health insurance %DDD pa auto insurance kaqt
  5. holger about 1 month later:
    home insurance =PP auto insurance quotes 8-[[ health insurance zsnd life insurance quotes pdikh
  6. d_TEL about 1 month later:
    description of valium diazepam tablets pnza tramadol :(( valium 7231 buy valium from europe online teh
  7. choose about 1 month later:
    buy tramadol =( accutane =O tramadol 7531 internet pharmacy propecia soma zoloft 5154 viagra for sale mhk ultram 32554 aciphex %(((
  8. sendusername about 1 month later:
    xanax 034 tramadol apap 85675 affordable health insurance 9419 health insurance :D aciphex yohuqz valium dosage gho
  9. ellcvx about 1 month later:
  10. regina about 1 month later:
    tramadol 646169 are ultram pain pills addictive qdlnrz valium 7958 home owner’s insurance 41962 order valium :O accutane whght ultram time released pill mpoboo car insurance online 8]]
  11. plexproject about 1 month later:
    new york health insurance >:)) valium purchase online from europe %-PP accutane %-))
  12. bilse about 1 month later:
    online casino 376 levitra >:(( health insurance quotes :-( accutane bwjpl
  13. cobby about 1 month later:
    online casinos zaxxcq health insurance coverage :-] affordable health insurance 476 new jersey car insurance znqq
  14. zithromax and hemroids about 1 month later: