limbera: why would tou have the same assets on each app?
bah... they left
lindii that was for
limbera
wrong person FunkyBob
yup
yeukhon joined the channel
FunkyBob
that's what I get for trusting tab completion :P
arustam joined the channel
bathtub95 joined the channel
mfcovington has quit
LeaChim has quit
the_rat_ has quit
dkb20k joined the channel
LeaChim joined the channel
limbera
hehe
Sir_Narwhal joined the channel
garrypolley has quit
radez is now known as radez_g0n3
bspkrs is now known as bspkrs|out
bkuberek_ has quit
streety has quit
fcoelho joined the channel
Goopyo has quit
fcoelho has quit
Huterich joined the channel
Huterich has quit
zzebelzz has quit
bkuberek joined the channel
bwreilly joined the channel
bspkrs|out is now known as bspkrs
mjt_ joined the channel
zzebelzz joined the channel
jfkdaddy
Any suggestions on forcing a JOIN?
FunkyBob
jfkdaddy: sorry, back...
joins are handled implicitly
streety joined the channel
windyhouser joined the channel
if you do Drink.objects.prefetch_related('ingredients_order') that will do 2 queries -- one for the Drink objects, and one for related ingredient_order records
mjt_ has quit
it then pre-fills the ORM so each Drink will have all its related 'ingredient-order' records already
if you also include select_related('ingredients_order__ingredient') it should follow on and pre-load the related ingredient to each ingredient_order record
jfkdaddy
Here's the JOIN I'd like to do, but if it ends up being two queries instead of one, that's fine for now. [SELECT cocktail_id, name, `order`, color FROM menus_cocktailingredientorder JOIN menus_ingredient ON menus_ingredient.id = menus_cocktailingredientorder.ingredient_id WHERE cocktail_id IN (...) ORDER BY cocktail_id]. Let me chain those two together and see what happens.
grantfunke_ joined the channel
schinckel
jfkdaddy: FunkyBob's point was that the ORM emits two queries when you use prefetch_related()
unbracketed joined the channel
bind has quit
bind joined the channel
ijij has quit
jfkdaddy
Ok, that makes sense and lines up with what I'm seeing.
limbera has quit
N1cXP8ChUBFe3
On the topic of ModelForms: There is a known and specific field that must be conditionally excluded from my form depending on the state of the model instance that was passed into the form's constructor. Perhaps my issue is that I don't understand the relationship between class Meta and the __init__ method? https://dpaste.de/qPTg
Boom! That helped a lot. Now I'm down (minus the COUNT(*) query) to one SELECT each for the cocktail, cocktailingredientorder, and ingredient tables.
FunkyBob
sweet
the Prefetch might bring that down to 2, instead of 3
but... 3 is still better than N*M*2 :)
kaakku joined the channel
jfkdaddy
FWIW, drinks.prefetch_related('ordered_ingredients__ingredient') seems to get the job done by itself without .select_related('ordered_ingredients__ingredient').
ub1quit33_ has quit
FunkyBob
yes, it will
sorry, I wasn't clear about that
jfkdaddy
No worries at all, dude. You've helped me out a ton.
Thank you!
I think I can get rid of the (seemingly silly) COUNT(*) from Paginator by setting its _count attribute to something high.
dray3 has quit
sligodave joined the channel
Genitrust joined the channel
unbracketed has quit
sligodave has quit
Sir_Narwhal has quit
zzebelzz has quit
Genitrust has quit
amizya has quit
prabampm has quit
windyhouser has quit
Swambo has quit
Swambo joined the channel
prabampm joined the channel
prabampm has quit
dmclain joined the channel
fuzzyplanet joined the channel
prabampm joined the channel
N1cXP8ChUBFe3
FunkyBob: Just seems like there should be a simple way to conditionally blacklist fields of a new ModelForm instance without using factories etc. Calling del self.fields['field_name'] from inside __init__ results in passing the "walks and quacks like a duck" test, and I have similarly appended new fields this way in previous forms. But what are the caveats to calling del self.fields['field_name'] from inside the __init__
method? Does the exclude attribute offer any solutions?
Left_Turn has quit
mattmcc
Eh, I remove fields in the constructor all the time..
N1cXP8ChUBFe3
mattmcc: care to enlighten me? :)
mattmcc
Seems like you already know how to do it.
N1cXP8ChUBFe3
mattmcc: grr. I guess the exclude attribute was misleading me.
Oh well, I guess that clarifies things... thanks.
schinckel
I prefer to explicitly include fields on a ModelForm.
atula joined the channel
Swambo has quit
dustinfarris has quit
kaakku is now known as Guest32717
kaakku joined the channel
N1cXP8ChUBFe3
schnickel: I do unconditionally whitelist fields via the Meta class, but I use the same form to update previously created objects. One of the attributes of those objects might be read-only so sometimes I have to blacklist the field from the form when its being used modify an existing object.
raleigh joined the channel
FunkyBob
which is where I would define a common base class, and a sub class with the include fields I want for the Add versus Edit modes
and you can just leave all the per-field clean methods on the base class
IIRC, there was also a newer discussion about LIMIT 21, too.
FunkyBob
ah, ok
atula has quit
solofight has left the channel
donspaulding has quit
Swambo joined the channel
mribeirodantas has quit
kaakku has quit
bathtub95 has quit
vipul_ has quit
codeitloadit joined the channel
jfkdaddy has quit
jfkdaddy joined the channel
ragsagar has quit
dmclain has quit
robbyoconnor joined the channel
grantfunke_ has quit
jfkdaddy groans.
jfkdaddy
So tacking on .prefetch_related(_menu) [drinks = drinks.prefetch_related('ordered_ingredients__ingredient').prefetch_related('menu')] gets me a nice SELECT ... IN for the relevant rows, but when I iterate through drinks, accesses to drink.menu.get().neighborhood aren't cached and yield a ton of SELECTs on the menu table.