Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed #166 -- Highlight the significance of the double underscore syntax #169

Merged
merged 1 commit into from
Nov 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions django_models/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -118,6 +118,8 @@ Let's open `blog/models.py`, remove everything from it and write code like this:
def __str__(self):
return self.title

> **Note** Double-check that you used two undescore characters (`_`) on each side of `str`. Those are used frequently in Python and sometimes we also call them "dunder" (short for "double-underscore").

It is scary, right? But no worries, we will explain what these lines mean!

All lines starting with `from` or `import` are lines that add some bits from other files. So instead of copying and pasting the same things in every file, we can include some parts with `from ... import ...`.
Expand Down
2 changes: 2 additions & 0 deletions django_orm/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,8 @@ Or maybe we want to see all the posts that contain a word 'title' in the `title`
>>> Post.objects.filter(title__contains='title')
[<Post: Sample title>, <Post: 4th title of post>]

> **Note** There are two underscore characters (`_`) between `title` and `contains`. Django's ORM uses this syntax to separate field names ("title") and operations or filters ("contains"). If you only use one underscore, you'll get an error like "FieldError: Cannot resolve keyword title_contains".

You can also get a list of all published posts. We do it by filtering all the posts that have `published_date`:

>>> Post.objects.filter(published_date__isnull=False)
Expand Down