pingveno: I don't mind if I get the months as numbers
MikiSoft
it really was *that* simple
i have just 'converted' cnk raw sql query to django orm
reisio has quit
subho has quit
cnk
except you are not guaranteed that Event is content type 17
MikiSoft
yeah i'll change that
to this: ContentType.objects.get(model='event')
adamsilver has quit
amcorreia has quit
also i'm trying to figure out how to filter only object_id in queryset, because maybe it would be a performance hit since it unnecesarily queries other fields too
and i need only that field
royendgel joined the channel
and it performs the query twice
but i don't see the other way of doing it
GeorgeMCW_work has quit
therefore, cnk, it would be slower than using .raw()?
in the case of ORM it's executing the query *twice* so that's the reason why it's much slower
raijin joined the channel
in the case of .raw() it's executing it only once
but i don't know the other way of doing it in one query in ORM
jbitcm- has left the channel
jbitcm- joined the channel
maybe it can be made through .extra() command to be faster but i'm not enough experienced to make it
mcspud
You're timing 2 things, you're timing the time it takes to convert chained method calls into SQL, and then the time to actually run the SQL
andyt_ joined the channel
type this instead: model.objects.filter(pk__in=target.objects.filter(content_type=CONTENT_TYPES[model.__name__.lower()], person=person).values_list('object_id', flat=True)).query
The .query flag will give the SQL you can use to time
andyt has quit
MikiSoft
yeah but then it would give me the query which does the other half of the job
finally made it with extra(), now it returns QuerySet instead of RawQuerySet
boxbeatsy joined the channel
boxbeatsy
hi all, i'm currently using python-memcached w/ my django app. i recently had a degradation problem which caused all memcached server requests to freeze, which resulted in 503 errors to my users (since the request took longer than 30s to process). what would be the best way to degrade gracefully in the future? i'd like for each memcached call to fail silently (or return None) if it takes longer than 0.1s.
i've been trying to find some good django assessment tests - does anyone have links to some free content?
what i mean is assessing someones knowledge of django, not writing test code
sebastian-w joined the channel
deltaskelta
How would you go about calling an API in your views? Seems easy but I am drawing a blank...https://dpaste.de/FaNn#L7,8
hamub joined the channel
poz2k4444 joined the channel
jessamynsmith
deltaskelta: um, usually you're either making an ajax request, using javascript, from the rendered view
or you're calling python code directly
what are you trying to do?
limbera
deltaskelta: you can use requests to make an HTTP request to whatever service you need
if the service is large enough they may even had a python SDK you can use
stickperson joined the channel
jessamynsmith
limbera: ah, you are calling someone else's api?
deltaskelta
I want to call my DRF API from another view within my own project, and display the data along with custom forms and context...
limbera
why not just call the function directly?
or abstract the logic into a function - and then have the API endpoint call that abastracted function
jessamynsmith
right, so if you want to get data from your own, you should... what limbera said
limbera
and your other function do the same thing
jessamynsmith
you can call the serializer directly and get the data from it, if that's what you need
deltaskelta
hmm ok I'll try to make sense of some of that and try it out in my code. Thanks
shangxiao joined the channel
zivester joined the channel
kyheo joined the channel
zamro has quit
religious has quit
zamro joined the channel
mcspud
Hey, I've been through the docs and can't see it. If I mock something out, and I access to a Call object, how do I access the arguments that were passed to it? Like this: https://dpaste.de/TSOm
ADubhlaoich has quit
deltaskelta
jessamynsmith: limbera: I am having some trouble calling the function directly like you were talking about. I know its right in front of me but I can't see how to do it.https://dpaste.de/Gn6H