Fuyou sorry my internet got disconnected for a second
oblikoamorale joined the channel
lordofthekebabs has quit
Fuyou
damn, those names confuse me, a moment please ^_^"
lordofthekebabs_
Fuyou thats okay thanks a lot for trying to help :)
kutenai
Greetings all. I have a question about best practices, related to the ORM. I teach my development team this is the 'standard style' https://dpaste.de/emvg, but I don't know that I can point to a particular document(s) that define "standard".
Fuyou
I believe your try\except hides the original error, though I think my line was incorrect here
Lazerskates has quit
nevertheless
lordofthekebabs_
oh my bad
Fuyou
User.objects.filter(followed__follower = current_user) ty this
outside of try: preferably
lordofthekebabs_
alright a sec
kutenai
They submitted some code that uses this approach -- Model.object.filter(pk=pk).first().. and I'm like that's not the standard way to do it.. but then, I'd like to be able to point them at some reference for "standard". If anyone knows of a good reference or two along these lines, I'd appreciate the links
Papinak joined the channel
Papinak
Hello
How django know about '[:5]' in 'Article.objects.all()[:5]'. I thought django will get all articles, and then python slice it. But not. Django add LIMIT 5 to the SQL query.
lordofthekebabs_
oh yes Fuyou it worked
Papinak
How is it possible?
lordofthekebabs_
thank you very much but what is this way much more advanced level of querying that i dont have to worry about for now?
i didnt see any of this magic in tutorials
apollo13
Papinak: because you can control what slicing does in python
mattmcc
Papinak: For a given object type, you can customize what [x] does.
Papinak
+apollo13 Oh. thanks.
Fuyou
lordofthekebabs_, it would be a bit more simple if you actually used a many-to-many field, it would simplify a bit. And your related names were not chosen in a best way
Papinak
+apollo13: Can you send me link for that? I can't find it.
Fuyou
lordofthekebabs_, ok, so it returned all followed users?
lordofthekebabs_
yes it did but
now how would i user this in the for loop ? in the temp
okay i dont even know what related name is doing i just used it since the dj debug gave a hint
ooooooooooohhhhhh
it just clicked
but why not just use filter(follower=current_user)
isnt it the same thing
why add the related name
Fuyou
it's like "FollowingModel has followed User -that means-> User has number of FollowingModel instances which will be addressed by related_name=followed"
lordofthekebabs_
oh its like a bad many to many trleation ship ?
joshbright joined the channel
joshbright has quit
thats why you were saying use many to many
Fuyou
why bad? As I said what you have implemented is basically a many-to-many. You just didn't use a convenience shortcut which is ManyToManyField
lordofthekebabs_
now i get it
again thank you a lot for taking your time to help me
have a nice day :)
finster joined the channel
joshbright joined the channel
Fuyou
so User has 'followed' field, which return queryset of FollowingModel's which you can query on FollowingModel.follower
lordofthekebabs_
now i understand why you said i should name them better
nobodi joined the channel
Fuyou
Well, it takes some time to sink in, it did for me at least