Skip to content

Instantly share code, notes, and snippets.

@hminnovation
Last active September 5, 2016 17:12
Show Gist options
  • Save hminnovation/93f2ff85d55450bfef70eeacdcd9b242 to your computer and use it in GitHub Desktop.
Save hminnovation/93f2ff85d55450bfef70eeacdcd9b242 to your computer and use it in GitHub Desktop.
Related name `+`
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