Learn Django - f() Expressions - Django Built In Expressions - DB Performance

preview_player
Показать описание
Welcome to another Django tut, here in this Django Theory Series we take a look at the F() Expressions, a built in Django Expression. Within Django there are a number of built-in expressions that can be used to help you write queries. They can offer great performance benefits as well as supporting and enabling more complex computations. Here in this session we look at understanding the F() Query Expression. F() Query Expressions can Offload the work to the database, Reducing the number of queries and help avoid database race conditions.

👍Check out more tutorials in this series:

SUBSCRIBE to get more free tutorials, courses and code snippets!

Follow us on Facebook

Follow use on Twitter:
Рекомендации по теме
Комментарии
Автор

Beautiful presentation. I especially appreciate the simple and focused topic coverage, perfect for anyone on the Django learning journey wondering, 'what are these F() expressions for and why would I want to use them?' Similar treatment on Q expressions would be a nice complement to this one.
Looking forward to everything in your Django series.

jwesleyb
Автор

thanks..i have just subscribed you because i like the way you presented the thing, i got the idea how to solve my problem.thank you

pawansharma-xnxp
Автор

I believe there is a mistake. It honestly confused me, so I hope you can edit if possible. At time 5:14, the second line of code should be votes.updated.... with a small letter v not a V. Makes a huge difference

ramielwan
Автор

in postgres think you have to set count field default to 0 in model before migrate as F(None)+1 = None but F(0)+1 = 1

rossgeography
Автор

on 4:54, is F('totalvote') supposed to be F('totalvotes')? did you make a typo or is this intentional?

simonm
Автор

This seems to be a very nice and a detailed video. Really appreciate your work. Now my question is, how does the F() expression know which column in which database table am I trying to update? Suppose there were 2 models with the same field votes?

for example:

votes1 = Votes1.objects.get(id=1)
votes2 = Votes2.objects.get(id=1)

Here suppose both the models Votes1 & Votes2 have the same attribute totalvotes
then, what would F('totalvotes') + do?

to which table would it increment?

dheerajlalwani
Автор

Great video.
One question: F expressions look like a super feature. So, why not use them always? When not to use them?
Thanks

MagnusAnand
Автор

If we use update(), then do we need to again save the object?

bringinglife
Автор

This would be a lovely video, but the two typos (the capital "V" in votes and the missing "s" in "totalvotes") make things very confusing.

kamilgovender