From 10e4f989f78c33b8db89e20eaad8d74a0d0b14f0 Mon Sep 17 00:00:00 2001 From: feyrkh Date: Sun, 29 Sep 2024 02:03:35 -0500 Subject: [PATCH] Fix alternate misspellings --- .../Part1/Beginner-Tutorial-Django-queries.md | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/docs/source/Howtos/Beginner-Tutorial/Part1/Beginner-Tutorial-Django-queries.md b/docs/source/Howtos/Beginner-Tutorial/Part1/Beginner-Tutorial-Django-queries.md index a34d63e01d..dae9d32da6 100644 --- a/docs/source/Howtos/Beginner-Tutorial/Part1/Beginner-Tutorial-Django-queries.md +++ b/docs/source/Howtos/Beginner-Tutorial/Part1/Beginner-Tutorial-Django-queries.md @@ -192,7 +192,7 @@ Don't confuse database fields with [Attributes](../../../Components/Attributes.m - **Line 7**: ... We also want only Characters with `Attributes` whose `db_key` is exactly `"lycanthropy"` - **Line 8** :... at the same time as the `Attribute`'s `db_value` is exactly 2. -Running this query makes our newly lycantrophic Character appear in `will_transform` so we know to transform it. Success! +Running this query makes our newly lycanthropic Character appear in `will_transform` so we know to transform it. Success! ```{important} You can't query for an Attribute `db_value` quite as freely as other data-types. This is because Attributes can store any Python entity and is actually stored as _strings_ on the database side. So while you can use `__eq=2` in the above example, you will not be able to `__gt=2` or `__lt=2` because these operations don't make sense for strings. See [Attributes](../../../Components/Attributes.md#querying-by-attribute) for more information on dealing with Attributes. @@ -201,7 +201,7 @@ You can't query for an Attribute `db_value` quite as freely as other data-types. ## Queries with OR or NOT All examples so far used `AND` relations. The arguments to `.filter` are added together with `AND` -("we want tag room to be "monlit" _and_ lycantrhopy be > 2"). +("we want tag room to be "monlit" _and_ lycanthropy be > 2"). For queries using `OR` and `NOT` we need Django's [Q object](https://docs.djangoproject.com/en/4.1/topics/db/queries/#complex-lookups-with-q-objects). It is imported from Django directly: @@ -228,7 +228,7 @@ works like `NOT`. Would get all Characters that are either named "Dalton" _or_ which is _not_ in prison. The result is a mix of Daltons and non-prisoners. -Let us expand our original werewolf query. Not only do we want to find all Characters in a moonlit room with a certain level of `lycanthrophy` - we decide that if they have been _newly bitten_, they should also turn, _regardless_ of their lycanthropy level (more dramatic that way!). +Let us expand our original werewolf query. Not only do we want to find all Characters in a moonlit room with a certain level of `lycanthropy` - we decide that if they have been _newly bitten_, they should also turn, _regardless_ of their lycanthropy level (more dramatic that way!). Let's say that getting bitten means that you'll get assigned a Tag `recently_bitten`. @@ -256,12 +256,12 @@ That's quite compact. It may be easier to see what's going on if written this wa from django.db.models import Q q_moonlit = Q(db_location__db_tags__db_key__iexact="moonlit") -q_lycantropic = Q(db_attributes__db_key="lycanthropy", db_attributes__db_value__eq=2) +q_lycanthropic = Q(db_attributes__db_key="lycanthropy", db_attributes__db_value__eq=2) q_recently_bitten = Q(db_tags__db_key__iexact="recently_bitten") will_transform = ( Character.objects - .filter(q_moonlit & (q_lycantropic | q_recently_bitten)) + .filter(q_moonlit & (q_lycanthropic | q_recently_bitten)) .distinct() ) ```