if not, change 'dev' in that URL to the version you'r using... e.g. 1.4
refu
mmm I am using 1.4
because I am installed Archlinux as principal OS
cramm joined the channel
this OS always have the last version of almost softs
amccloud has quit
smill
funkybob: just the man i was looking for, you always seem to know what you're talking about, may i ask you a legacy db question?
FunkyBob
refu: wow, you're using a distro provided package? brave
amccloud joined the channel
smill: you overestimate my skills :)
ask away
refu
mmm, i dont know, I install django for aur xD
Boydy joined the channel
medj
OK, thanks!
medj has quit
FunkyBob
refu: learn to love virtualenv :) then always pip install
smill
funkybob: ok well basically i have a legacy db that has an items and sections table, then a third table called Section_Items that just has the section id and item ids to link them together, because each item can be in multiple sections
funkybob: that was my general impression but i can't for the life of me figure out how to set it up! i have read about manytomany things but it seems to be adding functionality and i'd have to manually go through and redo the "links" between the tables
skandocious joined the channel
refu
ahhh yes! I listen about virtualenv
skandocious
if i execute Person.objects.get(id=1) 10 times in a function, does it hit the DB 10 times?
or are the latter 9 times pulled from a cache?
FunkyBob
smill: create a model for Section_Items, and set it as the 'through on a ManyToMany field on one of the models
skandocious: I'd hope it would hit it 10 times
skandocious
FunkyBob: thats what i figured
bubu___ joined the channel
FunkyBob: i'm doing a CSV dump function that resolves FK's before dumping
FunkyBob: and its resolving the same keys over and over...
bulkan has quit
FunkyBob: takes FOREVER
FunkyBob
skandocious: yeah, that's why we made cache dicts...
but more flexible, yeah... memoize can take more arguments
skandocious
FunkyBob: yeah
cibermarsam has quit
FunkyBob
of course, you'll probably find select_related would save you all [most of] those hits anyway
skandocious
FunkyBob: will it?
won't that resolve all the foreign keys in 1 swoop?
FunkyBob
it'll do it as part of the initial query
skandocious
i don't necessarily want to resolve all of them… that might be expensive…
chrisramon joined the channel
FunkyBob
then tell it which ones you do know you want to reolve
skandocious
plus if 2 tuples point to the same FK, that FK will get resolved twice
FunkyBob
resolve
yes, but it's still JUST ONE QUERY
skandocious
tuple1.select_related() // resolves FK
smill
funkybob: I tried this http://dpaste.com/899096/ note the contained_items in the Sections model. it doesn't work tho, I hate to ask you to spell this out for me but I have been screwing with it for a couple hours and I can't get it
skandocious
tuple2.select_related() // resolves same FK again
mgrouchy joined the channel
FunkyBob
skandocious: huh?
skandocious: do it as part of your QuerySet
I have no idea what tuple1 and tuple2 are supposed to be there
skandocious
FunkyBob: ohhh the original objects.all() call
by tuple i mean row/model-object
FunkyBob: but yeah i get what you're saying now
FunkyBob
MyModel.objects.select_related() ...
skandocious
FunkyBob: gotcha
FunkyBob
smill: I see the problem.. you haven't expressed the relations
fortunately, your schema follows django's field naming :)
also, no need to define an Integer primary key whose name is 'id'
though you may want to ensure it's using .... whatever implementation of PK sequence generation your DBMS uses
vbabiy joined the channel
atula joined the channel
bvlaar has quit
bvlaar joined the channel
smill
funkybob: ok, thanks, that makes sense. however i'm still getting the same error "'Sections" object has no attribute 'contained_items_set'"
chrismed has quit
repsaj has quit
robbyoconnor has quit
FunkyBob
that's because it doesn't
you called the m2m "contained_items"
cramm has quit
the '_set' suffix is only used for _auto-generated_ reverse references
so, for your case, Items will have a sections_set property
plabo joined the channel
Sharebear has quit
odarbelaeze joined the channel
Amitash
I currently have a view which returns: return render_to_response('login.html',{'state':state, 'username':username}). I have created a csrf_token in this view and I need render_to_response to return this as well.. How do I change the return statement?
Technodrome has left the channel
FunkyBob
Amitash: firstly, you will finde life easier [especially hwne using csrf] to use render, not render_to_response
smill
funkybob: I tried section.itemlist = Items.sections_set.all() and it says "'ManyRelatedObjectsDescriptor' object has no attribute 'all'" :(
odarbelaeze
Hi there, I'm using django boilerplate, in a medium sized project, its time to start tryals with DEBUG = False, but I'm getting a mysterious 500 error each time I set the flag to false
FunkyBob
Amitash: the reason is render() will use a RequestContext
Amitash: [and there's less typing :)]
odarbelaeze: have you written a 404 template?
odarbelaeze
I there any way to figure out what is happening, the only thing I'm getting is "GET / HTTP/1.1" 500 27?