Skip to content

Commit

Permalink
adds a thorough example of how the case sensitivity works
Browse files Browse the repository at this point in the history
  • Loading branch information
fredkingham authored and davidmiller committed Oct 26, 2018
1 parent b0f06e5 commit 2cf33f8
Showing 1 changed file with 29 additions and 1 deletion.
30 changes: 29 additions & 1 deletion doc/docs/reference/core_fields.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# opal.core.fields
# opal.core.fields

The `opal.core.fields` module contains helper functions for working
with fields, as well as custom Opal field definitions.
Expand Down Expand Up @@ -35,3 +35,31 @@ or as the value in a CharField.

By default this is case insensitive, pass in `case_sensitive=True` to make
it case sensitive when matching against lookup lists or synonyms.

e.g.
```python
class Duck(object):
name = ForeignKeyOrFreeText(Name)
show = ForiegnKeyOrFreeText(Show, case_sensitive=True)

Name.objects.create(name="Scrooge")
Show.objects.create(name="Duck Tales")

scrooge = Duck()

# by default we are case insensitive, so this will be saved
# as a foreign key to a Name object
scrooge.name = "scrooge"
# ie now
scrooge.name == "Scrooge"
scrooge.name_fk == Name.objects.get(name="Scrooge")


# this is not a case sensitive field so will be stored on the model as free
# text
scrooge.show = "duck tales"

# ie
scrooge.show_ft == "duck tales"

```

0 comments on commit 2cf33f8

Please sign in to comment.