We're sorry but this page doesn't work properly without JavaScript enabled. Please enable it to continue.
Feedback

I Didn't Know Querysets Could do That

00:00

Formal Metadata

Title
I Didn't Know Querysets Could do That
Title of Series
Part Number
9
Number of Parts
52
Author
License
CC Attribution - ShareAlike 3.0 Unported:
You are free to use, adapt and copy, distribute and transmit the work or content in adapted or unchanged form for any legal and non-commercial purpose as long as the work is attributed to the author in the manner specified by the author or licensor and the work or content is shared also in adapted form only under the conditions of this
Identifiers
Publisher
Release Date
Language

Content Metadata

Subject Area
Genre
Abstract
QuerySets and object Managers are a core part of Django, and can be extremely powerful. But I didn't always know about some of their more advanced capabilities. BASIC METHODS You have likely used filter(), exclude(), and order_by(). You've even probably used an aggregation method like Sum() or Count(). Less common, however, are query(), only()/defer(), and select_related(). F EXPRESSIONS / Q OBJECTS For some more complex queries, those basic functions and filters won't cut it. How do you construct a query that needs to check for field A or field B? What do you do if you need to multiply two fields together and then sum them? Look no further than F() and Q(). RAW SQL / THE EXTRA() METHOD As a last resort, it's entirely possible to use raw SQL queries to get the database results that you need. The sky's the limit, but there are definitely downsides to this approach; pitfalls include SQL injections and database backend portability issues. MANAGERS A talk on QuerySets would be incomplete without mentioning Managers, and how to leverage Manager customization to make your life easier. Writing methods on existing Managers, and creating custom ones can go a long way towards being DRY and reducing the potential for errors.
Set (mathematics)Query languageWordWeb 2.0Object-oriented programmingOrder (biology)PRINCE2DatabaseEndliche ModelltheorieLetterpress printingRight angleSequelInstance (computer science)InformationMultiplication signIntelligent NetworkShared memory1 (number)Moment (mathematics)Point (geometry)Electronic mailing listReal-time operating systemLine (geometry)Reverse engineeringField (agriculture)Product (business)Water vaporExpressionCategory of beingMappingResultantParticle systemTheoryWeb pageNetwork topologySocial classExpert systemForm (programming)NumberParameter (computer programming)Black bodyMathematical optimizationTable (information)Key (cryptography)Functional (mathematics)AverageCountingBitCustomer relationship managementElectric fieldPhysical systemFitness functionMereologyMobile appDampingExecution unitSummierbarkeitStack (abstract data type)Buffer overflowRevision controlData dictionaryFunctional (mathematics)Arithmetic meanData structureLoop (music)Exception handlingType theoryIntrusion detection systemTemplate (C++)QuicksortStatement (computer science)UMLComputer animationLecture/Conference
Type theoryPurchasingElectronic mailing listField (agriculture)Right angleOrder (biology)Water vaporTotal S.A.Social class1 (number)Source codeQuery languageRelational databaseObject-oriented programmingMultiplication signProduct (business)UsabilityDatabaseForcing (mathematics)Functional (mathematics)SpacetimeSystem callDistanceCASE <Informatik>Set (mathematics)Customer relationship managementArray data structureLine (geometry)WordMappingElectric fieldDatabase transactionTerm (mathematics)Insertion lossExpressionEmailOperator (mathematics)Complex (psychology)TheoryConnected spaceInstance (computer science)Self-referenceTrailResultantSummierbarkeitCodeView (database)Inverter (logic gate)Odds ratioMetric systemProcess (computing)Atomic numberExecution unitCondition numberClosed setBoom (sailing)Single-precision floating-point formatFunctional (mathematics)Boss CorporationEndliche ModelltheorieLoop (music)Intrusion detection systemData conversionResponse time (technology)Computer animation
CASE <Informatik>DatabaseTheoryRevision controlRight angleNumberFunctional (mathematics)SequelSingle-precision floating-point formatCountingWrapper (data mining)Function (mathematics)Line (geometry)Equaliser (mathematics)ExpressionEndliche ModelltheorieOrder (biology)Functional (mathematics)Table (information)DataflowEmailSign (mathematics)Portable communications deviceQuery languageDifferent (Kate Ryan album)Object-oriented programmingCondition numberCausalityNeuroinformatikExtension (kinesiology)Selectivity (electronic)Game controllerFormal grammarParameter (computer programming)Social classBitGoodness of fitExecution unitField (agriculture)Electric fieldIterationScaling (geometry)Product (business)Attribute grammarTraffic reportingProjective planeCodeIntegerString (computer science)Multiplication signLatent heatNetwork topologyProgrammer (hardware)Electronic mailing listRelational databaseCustomer relationship managementPhysical systemBeat (acoustics)DampingRaw image formatView (database)Point (geometry)WritingValidity (statistics)InternetworkingResultantType theoryHeegaard splittingComputer configurationInjektivitätCorrespondence (mathematics)MereologyFront and back ends2 (number)ForceCore dumpComputer animationLecture/Conference
MathematicsDifferent (Kate Ryan album)Statement (computer science)Category of beingEntire functionQuery languageNumberMusical ensembleCodeEndliche ModelltheorieLogicInstance (computer science)MereologyPredicate (grammar)Right anglePattern languageProgram slicingSound effect1 (number)Noise (electronics)Multiplication signSelectivity (electronic)BitNeuroinformatikFrequencyQuicksortArtificial neural networkQueue (abstract data type)Disk read-and-write headDatabaseFunctional (mathematics)Set (mathematics)Roundness (object)Limit (category theory)Computer animation
Computer animationXML
Transcript: English(auto-generated)