Last active
September 5, 2016 17:12
-
-
Save hminnovation/93f2ff85d55450bfef70eeacdcd9b242 to your computer and use it in GitHub Desktop.
Related name `+`
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| If you want to be able to make queries like "which myapp.FooPage pages use this image?", | |
| then you can deal with that by setting an explicit `related_name`. | |
| Usually we don't care about doing that, so we set `related_name='+'` | |
| to disable that reverse relation completely. | |
| Posted in #wagtail | |
| The main reason for using it is to avoid name collisions. | |
| If, say, you have two FooPage models in two different apps, | |
| and they both have a FK to image, they'll both try to create a | |
| reverse relation on `Image` called something like `foopage_objects`. |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment