« first day (2692 days earlier)      last day (2256 days later) » 
00:00 - 20:0020:00 - 00:00

12:11 AM
What is Ctypes?
@Simon Do you have any need to call C code from a python script?
 
DSM
I don't understand the connection between "I know C already" and "I'm not sure if ctypes is worth learning".
 
Is there an advantage to using Ctypes rather than just creating a C extension.
 
DSM
.. what would you use ctypes to do? Its whole purpose is to make it easy to connect with an external C library. Are you trying to compare "writing a CPython extension longhand in C" with "interfacing with a C library entirely written in C via ctypes"?
 
don't forget the all-important use case of "making 2+2 equal 5"
5
 
12:21 AM
@DSM No. I'm trying to make sense of one of my earlier questions that uses ctypes.
I can just learn the bare minimum for this purpose or learn it more in depth.
 
DSM
Then I'm back to thinking your question is comparing apples and oranges, like "is there an advantage to taking the bus rather than just visiting Paris", so I'll let someone else who might understand help you. :-)
 
Oh this was my question's answer: stackoverflow.com/questions/48549535/…
I've worked out GetStdHandle() and GetConsoleScreenBufferInfo() but I'm stuck "converting" it to C
 
DSM
Unsurprisingly, that answer uses ctypes to interact with an existing C API library, so I don't know why knowing C would be a detriment.
 
if I recall correctly Simon's been on a mission to learn the use of various modules for the purpose of knowing them
 
DSM
Let a thousand flowers bloom, etc.
 
12:40 AM
Nope ctypes is of little value to me. Even if I learn it I have C and in reverse it tells me as much without knowing it.
 
I'm glad we've cleared that
 
You can cross ctypes off your "Simon to learn libraries" list :-)
 
DSM
When I'm so confused that I keep reading "in reverse it tells me as much without knowing it" hoping it will start making sense, it's definitely time to go the gym.
Evening-exercise rhubarb for all!
 
rhubarb, but it's not your fault ;)
 
@DSM Thank you for you help. Rbrb.
No it's all my fault. What I actually meant that ctypes is useless because I can do the same in C (and faster probably)
But when faced with a ctypes python script I can still tell what it is doing because I mostly need to understand the calls it is making and not the python functions it is calling.
 
12:48 AM
don't take this personally but this discussion reminds me way too much of this trope
don't know if you've seen any 2 stupid dogs, I suspect not
 
You suspected correctly. I have not.
 
they don't make cartoons like they used to *shakes cane*
 
Indeed
 
1:07 AM
@Moo, I'm curious: does your trypophobia get triggered by huge dark submarine holes? I'd think not, but I find these really spooky anyway.
 
You put me in a nostalgic mood. I'm now watching old cartoon favourites.
 
1:21 AM
Rbrb
 
1:52 AM
hey guys, i am looking at the public servant budget records of the city of chicago, I am trying to find the number of employees and salaries/net wages of ever employee, then create a new dataframe. How do I take my successful group by and only sum one of the values.
I think I'm getting by for now just dropping unnecessary columns
 
can't you just index into the column you want?
df.groupby(...).colname.sum()
 
can you explain the .colname part there
dont think I've used that one before
 
As in df.colname as in df['colname']
 
so how would you write that after a group by
 
Rhubarb
 
2:03 AM
@AndrasDeak because in df.groupby().colname ... i dont see you actually passing a colname anywhere
 
2:19 AM
guys, for some reason when I concatenate two 1 column df a large number of the values in each of the columns seems to be lost and returns NaN on print
 
 
1 hour later…
 
1 hour later…
4:52 AM
https://stackoverflow.com/questions/49012093/unicode-error-on-non-ascii-character-while-replacing-string
here is my question
 
 
3 hours later…
7:23 AM
cbg
 
@KevinMGranger ho boy.
The plain Exception catch. Tsk tsk. And how does this interact with a recursive function that itself uses exceptions?
And it keeps re-running functions in the stack that were unsuccessful, so this is going to be dog-slow.
 
8:18 AM
also, cbg
 
cbg
 
cbg
@Aran-Fey I suppose the language creators were quite ... excited to add the feature in
 
user4229770
Hello Guys, good morning :) Has anyone worked with django MPTT ? :)
 
8:40 AM
@Arne: all rectified. And apologies to Aman, I missed the context.
But beyond that, "not much", not working on Instagram right now.
 
user4229770
Do you like django ?
 
user4229770
did*
 
@MartijnPieters What guidelines do you follow when writing commit messages?
If you don't mind my asking
 
@Marius I have a preference for Flask and SQLAlchemy.
SQLAlchemy is the better ORM, Flask gives me more flexibility.
@cᴏʟᴅsᴘᴇᴇᴅ dunno, nothing explicit. One-liner first message, blank line, details. That's about it. Avoid 'fixed things' type lack of detail.
 
Hey, guys. I have a problem with getting errorlevel in Python under Windows.
C:\Users\username>py -c "quit(1)"

C:\Users\username>echo %errorlevel%
1

C:\Users\username>py -c "from os import environ;print(environ['errorlevel'])"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "C:\Program Files\Python36\lib\os.py", line 669, in __getitem__
raise KeyError(key) from None
KeyError: 'errorlevel'

Is this worth posting a question or is it something stupid?
 
8:47 AM
@cᴏʟᴅsᴘᴇᴇᴅ dunno, nothing explicit. One-liner first message, blank line, details. That's about it. Avoid 'fixed things' type lack of detail.
 
I see. Would you describe the feature in terms of something you did? For example, "created a script to parse JSON data"
Or, would you rather describe what the code does?
For example, "parse JSON data"
 
Honestly, I don't usually think about it to this extend, experience kicks in and I haven't given it explicit thought.
Take a look at my recent Github commits, I suppose?
 
So, Bill Gates likes tabs, but that wasn't in a programming context as such, so, meh.
 
Sam
Hey @Arne curious to your thoughts on something ML related. I've got an algorithm which evaluates someones risk of experiencing some medical event. What I'm trying to do now is conceptualize a 2-step process incorporating 2 learner models.. the first acting somewhat as a filter removing patients of low risk and passing the higher risk to a more advanced model. Have you any experience with this?
 
also, cabbage!
 
8:59 AM
I can do that. Was hoping to hear it come out of the horse's mouth though ;D
cbg Ashish!
 
@AndyK ah crap, I see that the loving Python blindfold forbade me from reading the very start of that sentence
 
@AshishNitinPatil hé hé
 
> Tabs are 8 characters, and thus indentations are also 8 characters.
There are heretic movements that try to make indentations 4 (or even 2!)
characters deep, and that is akin to trying to define the value of PI to
be 3.
I don't know if I should feel good or bad now, but personally, I've always hated 8-spaces-width tabs. So, doesn't change my mind on them. Plus, today's editors are quite sophisticated (and you can also make vim / emacs bend to your needs), so this shouldn't really be too much of an issue.
 
 
1 hour later…
user4229770
10:43 AM
I have a Categories and Products, they can be active or inactive, I would like to show only active categories and products, what should firstly I do ? Try to get all active categories, then remove products from categories if they are inactive ?
 
@Marius σ activeCategory = true ((ρ activeCategory / active (Categories)) ⟕ (σ active = true (Products))) or so, iiuc.
 
user4229770
Thanks, but there are so unclear signs :/
 
Take categories, left join active products, limit to active categories.
 
user4229770
Could You later check my query ? :)
 
10:58 AM
@IljaEverilä What language is that!?
 
Relational algebra, or something close.
 
so I thought
@Marius Which framework? Django?
 
@Marius Not that familiar with Django ORM, but I guess the basics should be somewhat the same, excluding eager loading details and such.
 
user4229770
Yeah, Django
 
@Marius If your relations are setup properly, it should be as easy as
Products.objects.filter(is_active=True, category__is_active=True)
 
user4229770
11:12 AM
Actually I need to get categories and products:

I want categories as a result, but it should not contain inactive categories or inactive products
 
user4229770
categories = Category.objects.filter(is_active=True)
 
user4229770
Now it has only active categories, but how can I remove all inactive products from categories
 
well, where do you fetch the products?
 
Is it possible to adapt a subquery against a relationship in Django?
 
11:13 AM
Or to explicitly define the ON clause of a join, either would do
 
user4229770
Wait a sec
 
I've honestly used Django some 7-8+ years ago.
 
@IljaEverilä Django's ORM handles it well by itself
 
user4229770
I am using in a view something like this, also using MPTT:
{% recursetree categories %}
<li>
{{ node.name }} ({{ node.product_counts }})
<ul class="children">
{% for product in node.product_set.all %}
<li>
{{ product.name }} (${{product.price}})
</li>
{% endfor %}
</ul>
 
@IljaEverilä Django 2.0 should be a refreshing sight for you then :D
(sorry for double ping)
 
user4229770
11:16 AM
Can I use something like this:
Category.objects.filter(is_active=True).product_set.filter()
?
 
Nope
Generally, it's best to pass related objects in a separate variable
 
@AshishNitinPatil Was thinking along the lines of categories LEFT JOIN (product_categories JOIN products ON products.id = product_categories.product_id) ON product_categories.category_id = categories.id AND products.active or such.
 
But if you want to stick with .product_set.all, you can either write a custom Manager for your model which has a .all_active method that filters the active products of that category.
OR (not recommended), put an if statement within your {% for product in node.product_set.all %},
{% if product.is_active %}
 
user4229770
Nah... Cannot do that, later on i will need to count these products, how many active are in the category :S
 
Window functions!
 
11:20 AM
So go with the custom Manager solution, and instead of .all do .all_active or something
 
user4229770
Okay, need to google that :)
 
user4229770
Thanks!
 
@Marius this is mostly what I'm talking about - godjango.com/…
 
user4229770
Okay, thank You!
 
@Sam As always, impossible to properly evaluate without knowing much more about the problem. Now that that's out of the way, I usually write filters as rule engines and not a statistical model. Dealing with one model is hard enough, having two that depend on each other can be very mentally exhausting in case things go wrong, which they always do.
 
11:23 AM
@IljaEverilä Django ORM has gotten better (but might still be considered as restrictive or cumbersome by SQLAlchemy people), so you almost never have to write custom SQL :)
@Marius just the notes in that link are enough, I didn't mean to point to the video
 
I actually did do something similar, and in particular for medical data a model that estimates surprise for a verdict can be very useful. Then you are also back at two, but they second evaluates the first, and can also help you understand your data better.
Also, you probably care about recall much more than accuracy. A surprise estimator helps with that as well.
 
@AshishNitinPatil I was pretty close to ending up in a Django gig a while ago, but that'd required moving (the family) from Fin to US, so it dried up.
 
I reckon you made the right choice! I like Fin much more than US, specially since the last year or so.
Regardless of the last year, Finland and Norway are my top 2 go-to countries worth settling in.
 
@a
Wanna trade??
 
Can't, at least not right now :-p
Plus, weather-wise, we are talking about trading extremities
 
Sam
11:45 AM
@Arne Yeah I've been plotting precision-recall plots and calculating the AUC on them. I'll have to take a look at a surprise estimator
Do you have any useful resources?
 
user4229770
12:06 PM
@AshishNitinPatil Actually I posted on SO, so it does not require a manager to do that :P
 
user4229770
Do you want to know the answer ? A single line! :-)
 
@Marius Yeah, that one was nice, but it's a one-off hack, which is what you needed anyway I think. My answer was more for repeated use.
 
user4229770
Ohhh... okay :D Well, i hope it will workout :)
 
Btw, once your comments are no longer needed or relevant, you should ideally remove them.
@Marius It will work out, .prefetch_related is powerful and actually a good choice in this case because you were going to use .product_set in your template anyway. So, instead of 2 hits to the DB, there will be a single hit (in the view and not the template).
 
user4229770
Okay! Finally this one fixed, now need to check how to build a ManagerTree in MPTT...
 
12:14 PM
@AshishNitinPatil That's more of a 1+N situation, aka 1 query for the categories, N queries for products per category, if not done using eager loading.
 
Oh yeah, not 2, my bad.
(Unless there's only 1 category :-p )
 
@Sam Not really, sorry. Just trying a lot and reading up on statistics
 
12:30 PM
> Spaces are for aligning characters and method calls with delicate precision to create a masterpiece of impeccable readability ingrained in an elegant orchestra of dignified perfection. Whereas tabs are for butchers.
 
12:47 PM
Kevin from a week ago: The client asked for an "export widget blueprint" button, but didn't specify whether the output format would be .csv, .xls, or .blueprint, the impossibly difficult-to-implement ad-hoc specification that drove my predecessor into early retirement. I'll ask them what they meant.
Kevin from a week ago: hey, how should we export widget blueprints? .csv, .xls, .blueprint?
Client: Sure, those all sound good, do them all.
Kevin, today: ... Perhaps I could have worded that question better.
 
you had to ask
 
@Kevin "iirc. the initial plan was one format, i'll gladly add multiple formats for the low extra fee of $xxx" ;)
fwiw, csv/xls(x) are similar enough so a decent implementation can easily generate the data for both, something like this
 
1:12 PM
Yeah, at work we have an xls/csv recipe that we've used in a bunch of projects. They both call the same data generation function, and then slap on formatting/headers as befits their file format
Time to do front-end design. What color are to-do-apps, usually? Red?
 
1:33 PM
@Kevin Seems so: todomvc.com
 
Funny, I was just trying to figure out if I should be using MVC for this project.
I tried selecting MVC from Visual Studio's "new project" window and it popped up a window asking me to select my Microsoft Azure something-or-other but I don't know what that is so I clicked "cancel" and then it said "creating your project..." so I thought maybe it was going ahead anyway, and then it churned for a full minute, and then both of my monitors turned black for ten seconds, and now I have a project with eight folders, which is four more than the number of pages this project will have
 
@Kevin tweet MS that
 
I've sent to them my most trusty raven. Doesn't tweet much, though, more of a croak
Email from management: "Let's try using bootstrap/MVC/jquery/material design on this one". I mean, ok, fun new toys, but if they're all gonna almost-segfault like MVC did, [pulls comically at shirt collar]
jquery infamous for its tendency to bluescreen
 
1:49 PM
code inside the "global space" of a file is only run once on import right? - Even if multiple files import it, the code is guaranteed to only run once right?
 
Yeah. imports after the first one don't re-execute the code
Unless you manually screw with the module cache, but that's silly don't do that
But personally I try to avoid designs that execute a lot of stuff at the global scope. I keep it all in functions and if __name__ == "__main__": where possible
 
Hmm is using the module as a singleton then a good pattern?
 
Like, using it to facilitate communication between other modules? a.py and b.py both import c.py, and they mutate members of c with the expectation that the other file will see the change? I've done that once or twice before, but I prefer dependency injection these days
Rather than have a and b import c, I'd prefer that a import b and have them communicate directly.
 
Nah like making sure there's a single connection to a database used in the whole application.
 
That sounds fine to me.
This MVC tutorial reminds me a lot of the Flask tutorial that I did a couple weeks ago.
All the cool kids are doing map routing these days
 
2:16 PM
@AndrasDeak I didn't want to click it but since your question, but no, one giant hole is fine. It's many holes (doesn't matter of the size) that triggers it for me.... or holes within holes.
cbg \o
 
2:38 PM
recbg o/
 
2:49 PM
Looking at a text editor for a wiki website project for work. Id like to use something that works well with Microsoft Word as we have many documents written in word. Id like to get to the point where I could upload the file and edit any issues after uploading the .doc into the website's editor. Anyone have any thing they know of for that?
Ive been looking at ckeditor so far. Thinking I might be able to upload the word files as rtf files.
 
are you asking how to edit a .doc file or how to convert a .doc to something you wish? If former you can use docx if latter then up to your design and what you need.
do note, that the one time I had to use docx I didn't really enjoy the experience, but it got the job done for me, there might be other solutions out there which I'm not aware of
 
It sounds like he wants a rich text editor for his web page which can interface with .doc files.
I have no idea if such a thing exists. That's more of an html5/javascript question I think
 
Sorry got pulled onto a call right after sending that.
Yes kevin has it right. And yes I figured Id just ask in here before exploring to another room to see what you guys knew first.
 
As usual I am largely ignorant of the third party tool ecosystem
 
I may have to build something though from docx but would much rather it be done for me haha.
Id like it to work like stack with codeblocks included but they use MarkdownSharp. According to this post
Im reading on it now as well. But figured Id share that post as I found it pretty interesting as it describes all the tech SO uses.
 
3:07 PM
@MooingRawr I intentionally linked a benign wiki page rather than pictures of Eldritch-esque pits of the void ;)
and thanks for the feedback
 
anytime AD :D
 
Hey anyone experienced with sqlalchemy? - As my database is also spoken to by another application I wish to not let the sqlalchemy decide the table format: so I'm using sqlalchemy.ext.automap. Problem is: this is kind of really slow for a large database. It gets the full schema, yet I only require 3 tables of said database, can I specify which tables to "grab"?
 
3:41 PM
Question about my answer on this post I want to see if I should leave mine up or delete it based on the other guys answer. Would mine be better since I am only opening the file once?
 
without context: it's fine to leave suboptimal answers around as long as they aren't harmful
 
Incidentally if x in str(read_data) is redundant because read_data is already a string
 
you can always leave a note saying that the other answer is better if you're feeling nice
 
When I read it with .read() I got a byte type back. But Ill update it.
@AndrasDeak I wasnt sure which approach was better or more pythonic
 
I don't know if I like your answer because if both "word" and "word1" are in the document, it will print "True" twice and I suspect that OP only wants "True" to be printed zero times or one time
 
3:44 PM
As I hinted, I didn't open the link. I'm just saying that even if the other is better doesn't imply that yours should be deleted.
 
@AndrasDeak Makes sense. Thanks for explaining that.
 
@ZackTarr Curious. I'd expect that only to happen if you opened the file in "rb" mode.
 
Thats what I did the first time now that you say that. I was using open not with open and fixed both when I switched.
 
That explains it.
 
Based on the OP's comment it looks like I may have gotten it right. But I asked for more clarification.
But overall. Opening the file each time for every element in a list would not be good right? Or does python only open the file once then read from it?
Never mind the other guy added to his answer.
 
3:50 PM
Tripping a conditional multiple times in a loop when you only want to trip it once is a fairly common mistake among new-to-intermediate programmers. It's in the same category as this mistake:
with open("myfile.txt") as file:
    for line in file:
        if line == "foo":
            print("Found line containing foo!")
        else:
            print("Did not find any lines containing foo :-(")
Which I see quite frequently. The poster is surprised when they get N messages printed, where N is the number of lines in their file.
@ZackTarr Yeah, you don't* want to open the file more than once. Python doesn't do anything fancy there. If you ask it to open a file ten times, it will open it ten times with no caching or shortcuts or anything.
(*... Usually. In some instances you might be more concerned about memory than speed, in which case you'd prefer not to store a complete copy of the file in a variable. Then it may be necessary to open the file more than once.)
 
Then you would need to close the file 10 times right? And Ill keep my eye out for mistakes like those. Looks like the OP choose me to be the bread winner on that answer.
 
you probably can't close it 10 times unless you keep earlier references
 
I was about to say, any(x in open('Textfile.txt').read() for x in KeyWord) is extra bad because there's no way to close those anonymous file objects.
 
then again unreferenced file objects will probably get closed
 
Python should close them properly during garbage collection, but the details of GC are beyond the typical programmer and one should not depend on that kind of spooky behavior where possible
 
3:55 PM
not to mention that apparently reference counting is not considered part of the GC
 
Yep no clue GC even existed actually.
 
last time I was told that the GC is a big gun that kills circular references that are stuck
 
@AndrasDeak As I understand it, this is because objects whose reference count hits zero can be deallocated immediately, whereas you need a garbage collector if you want to deallocate objects which might have a nonzero reference count but which are nevertheless no longer accessible
 
yup
 
The former happening instantaneously after every statement*, the latter occurring infrequently whenever Python feels like it
(*or, maybe with more granularity than that? Not completely sure. But it's frequent.)
 
3:59 PM
but we should have a concise name for GC+refcounting
 
You could call it "GC" and hope that the listener can figure out from context that you're including refcounting
Which is what I do, because effort.
 
Then you need to sometimes say GC-refcounting
 
yes but around these parts it's not that the listener can't figure it out, it's that the listener knows that well actually it's not GC ;)
yes, the listener sucks
 
"Python should close them properly during refcounting, but the details of reference counts are beyond the typical programmer and one should not depend on that kind of spooky behavior where possible"
Fixed that for myself
 
Anyone ever try to use a client certificate from the windows certificate store for SSL?
 
4:06 PM
If that client certificate happens to have the correct key usage set up and includes a private key, and possibly a correct SAN to not mess with Chrome. Then yes, I have.
 
how do i load a p12 cert from the certificate store and use it? the ssl context expects a separate pem and key file
the p12 includes a private key
 
@Xample try passing the same file for both
 
> garbage collection
The process of freeing memory when it is not used anymore. Python performs garbage collection via reference counting and a cyclic garbage collector that is able to detect and break reference cycles. The garbage collector can be controlled using the gc module.
Hmm, Python's glossary would have me believe that both ref counting and cyclic garbage collection count as garbage collection
Perhaps it's correct to say that refcounting counts as "garbage collection", but the "garbage collector" only works on cyclic garbage.
Since no independent agent is required to deallocate refcount-0 objects; they more or less deallocate themselves.
(enormous overgeneralization but w/e)
 
@Xample Load it with what exactly? What are you trying to use here?
 
4:11 PM
Now the only problem is to make it clear whether "GC" stands for "garbage collection" or "garbage collector"
 
@ThiefMaster The certificate store has no “files”. It’s more a database for certificates.
 
@ThiefMaster I don't know what to do re: blog.index redirect in the tutorial.
 
@poke ah, didn't read the part of using the windows cert store
 
i have a p12 certificate (with a bundled private key) installed in the windows cert store. I want to use python to load that client certificate and use it for an ssl connection
 
If I redirect / to /blog/, there's no / route, which is weird.
If I don't register the index view as a blueprint route, and instead register it in create_app, there's no blog.index endpoint or /blog/ route, which is also weird.
 
4:13 PM
@Kevin I would say it all belongs to the topic “garbage collection” but ref counting itself is not part of the process of “collecting garbage”. The garbage collector will only collect those objects that are considered garbage by their ref count.
 
I was thinking of maybe just not adding a prefix to the blog blueprint, but then it feels weird to add one to the auth blueprint.
 
@Xample I don’t think there is a built-in way to communicate with the certificate store with Python but there may be some native extensions that allow you to do that.
 
Figured I would share this post. Its not python but something Im sure someone in here would be able to get some rep on. How computers convert decimal to binary integers
 
@poke I'm able to get the pem cert using ssl.enum_certificates("MY") or wincertstore, but it doesn't have the private key
 
Does the user running the application have permissions to read the private key? You need to set those permissions explicitly within the certificate store.
It’s possibly that those APIs simply don’t allow retrieving the private key though
 
4:19 PM
@Kevin so garbage collection includes when diligent citizens recycle, but the garbage collector is needed for all the trash that is left in the streets after a night of party downtown
 
That's how I'm reading it yeah
 
4:35 PM
@poke It's running as the same user that they key is installed for. It could just be that it can't get that private key. :(
 
user4229770
4:47 PM
Is there any chance that I could modify for example "Category.objects" so it could return be default filtered categories ?
 
user4229770
Django
 
custom manager
 
user4229770
Okay :)
 
user4229770
Will try google for custom manager :)
 
try the earlier link I'd shared, it's roughly similar, but yeah, see official docs :-p
 
user4229770
4:51 PM
But will it return QuerySet ? :)
 
@Marius Yes, it will be similar to your regular Manager, only the overridden methods will change as per your changes
 
user4229770
Okay! :)
 
user4229770
Thanks
 
So I'm looking to move on to learning one of the GUI frameworks for python. Anyone got any advice on which to get started on. I'm seeing PyQT/PySide (which I believe come as separate development applications), Tkinter (less visual dev app options), and Kivy (which has positive reviews, but seems to necessitate learning kivy language).
Since I'm primarily looking at apps that work offline, possibly in future needing web/database connectivity, and it appears web-app guis like Flask/Django require some server type setting app, I'm wary of even considering that for now.
 
5:03 PM
Ive used pyqt4 for most applications Ive made. Its pretty easy and has decent documentation. The visual designer is a nice plus in my opinion. I think pyqt5 is all the same minus a few differences. But Im not sure on what all they are
 
@ZackTarr Thanks.
 
user4229770
I guess pycharm community does not support django ? :)
 
What Pycharm community? I don't think their website even has a forum.
 
Yeah, PyCharm is a product
 
he meant community edition I suppose
 
user4229770
5:17 PM
I mean pycharm community edition :D
 
The pro edition has Django stuff
 
Ah, I misread the question. Carry on.
 
user4229770
Okay got it, @AshishNitinPatil I did with a manager, actually it filters, but I am curious how is filtering is done..

def get_queryset(self):
return super().get_queryset().filter(is_active=True).prefetch_related(Prefetch('product_set', queryset=Product.objects.filter(is_active=True)))
 
@ZackTarr At the moment I just want to make a simple GUI for a script I wrote. Later I'd like to be able to expand to something more complex, with remote database connectivity etc.
 
5:21 PM
Yep I have an app in pyqt that does just that. It connects to a local mysql DB but could be any DB at any IP.
 
@Marius what's your question?
 
user4229770
Well I have this Manager, but somehow: I call it like this:
 
user4229770
categories = Category.filtered_objects.add_related_count(
Category.filtered_objects.all(), Product,
'category', 'product_counts',
cumulative=True)

I see that cannot see filtered categories/products in a list, but somehow can see its count... no matter if is filtered or not
 
user4229770
But i need to debug and get the query, why is that... No idea how does it generate this query... I guess You have never worked with MPTT
 
user4229770
THe last thing is to fix this, for my new job :)
 
user4229770
5:25 PM
I was curious does it filter at the end of the query ?
 
5:37 PM
yes, everything is kinda lazy, unless you do prefetch.
@Marius See the highlighted "Note" section in docs.djangoproject.com/en/dev/ref/models/querysets/…
 
user4229770
But am I not doing that in a manager ? :)
 
doesn't matter where you do it, ultimately when the resultset gets consumed, that's when things happen
 
White cabbage all.
 
user4229770
So what shall I do ? :)
 
Hmm I was considering importing this zillion line library in order to do user validation because I figured it would require a million safety considerations and backflips but looking at the source I think it's just extracting the user's id from the http header
 
5:42 PM
@Marius seems like a good question for the main site :)
 
The other 999,999,999,999 lines are for getting other attributes of the user which I really don't care about. Maybe I'll just fiddle with the Request object on my own.
 
Kinda low on my brain's processing power right now
Just corrected 3 typos in the above comment...
And it still isn't grammatically nice
 
user4229770
There is no library with zillion lines
 
DSM
...
 
just in time for the fun, DSM
 
5:49 PM
cbg DSM :D
 
user4229770
6:02 PM
Could someone help me to convert sql to django orm ?
 
6:35 PM
1
Q: converting sql to Django ORM

Dauren ChapaevHow to convert this SQL to Django ORM SELECT `table1`.*, `tabl2`.* FROM `table1` INNER JOIN `table2` ON (`table1`.`table2_id` = `table2`.`id`) INNER JOIN (SELECT table2_id, MAX(date) AS max_date FROM table1 WHERE date <= CURRENT_DATE GROUP BY table2_id) grouped ON table1.table2_id =...

Anyone know the protocol for creating a custom bytes like object?
I'm trying to do something like this: file_obj.readinto(custom_obj)
 
6:55 PM
it's 16 C (61 F) today.... what happen to my winter :(
 
user4229770
16C ? Here is -20 C...
 
user4229770
ohh.. Your from Canada, my dream country :))
 
:D
we broke a 70 year record today for being warm on this day :\
 
@MooingRawr got it right here
 
afternoon cabbage
 
7:06 PM
we've had sub -10 Celsius for the past few days, it has just ended
 
18F here
google says that is -7.7777...C
 
trade me please. Also I found a weird bug. My developer story location has my city in it, when I don't specify the location on my SO profile, it takes my developer story location instead, is this a bug or intended behavior ? if it's a bug should I post to meta about it ? I have my developer story tab hidden from my profile
I'm happy when the weather is < 10 C :D
 
30C would be fine to me
I'd be happy with 20 C right now, even.
 
20 C is when I start having to have cold drinks with my meal and AC/Fan has to be on. 30 C is when I stop wanting to do anything :\ 40 C (happen to me once or twice), I literally stop doing anything.
I don't like the heat, and the heat knows this, it's a heated issue between me and mother nature.
 
@MooingRawr if you mean "private developer story location info is spontaneously leaking out into the public SO profile", that sounds a lot like a bug and you should ask. I took a look on meta and couldn't find anything related, so it might be some different issue, but it can't hurt to ask (assuming you make sure that this is exactly what's happening)
 
7:16 PM
well i assume it is since when i specify my location on my profile I can the new location
 
I'm happiest when 35 degC < temp or temp < 0 degC
 
btw how do you check if your developer story is private? (i assume it's unchecking the "Show the developer story tab")
 
@MooingRawr look at your profile in a private window/logged out?
@MooingRawr now, when you say "specify my location on my profile" you make me unsure, because what you originally said didn't involve you setting your location in your profile
please make sure you're communicating clearly and you're seeing a problem
 
@toonarmycaptain so you like extremely hot or extremely colde?
 
@AndrasDeak yup yup :P when I write up my question it should be clear
 
7:20 PM
I like snow and ice, or decently warm.
 
okie now that's weird, I can't reproduce it anymore :\
Sigh I'm just check it off as caching issues...
 
7:37 PM
i keep thinking today is a Thrusday :\
 
just hang on, you'll make it thur
 
what are you up to these days AD ?
 
not being sick
otherwise the usual
 
7:53 PM
usual is good. I still think one of the scariest word is "change" :\
 
00:00 - 20:0020:00 - 00:00

« first day (2692 days earlier)      last day (2256 days later) »