Skip to content

Commit

Permalink
Fixed #166 -- Highlight the significance of the double underscore syn…
Browse files Browse the repository at this point in the history
…tax.
  • Loading branch information
bmispelon committed Nov 8, 2014
1 parent 0d0e271 commit 5ac563c
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 0 deletions.
2 changes: 2 additions & 0 deletions django_models/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,8 @@ What about `def publish(self):`? It is exactly our `publish` method we were talk

Methods very often `return` something. There is an example of that in the `__str__` method. In this scenario, when we call `__str__()` we will get a text (**string**) with a Post title.

> **Note** Yes, there are two undescore characters (`_`) on each side. Those are used frequently in Python and sometimes we also call them "dunder" (short for "double-underscore").
If something is still not clear about models, feel free to ask your coach! We know it is very complicated, especially when you learn what objects and functions are at the same time. But hopefully it looks slightly less magic for you now!

### Create tables for models in your database
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").
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

0 comments on commit 5ac563c

Please sign in to comment.