Update relations.md (clarified view_name)

It wasn't clear how view_name was derived from the model name in the documentation. It's now broken out into its own section.
This commit is contained in:
tom-leys 2014-02-20 08:16:36 +13:00
parent 316b7b8786
commit 97be8fb720

View File

@ -132,6 +132,17 @@ Would serialize to a representation like this:
By default this field is read-write, although you can change this behavior using the `read_only` flag.
**View Name**:
The view name of your target must be specified using the `view_name` argument. The standard naming is `<model_name>-detail`.
`<model_name>` : Corresponds to the name of the model, forced to lowercase. In this example `Track` becomes `track`
`-detail` : Relates to either the detail view `-detail` or the list view `-list` of the related model.
Note however: When you define a Serialiser, you can customise the `view_name` argument by specifing a custom one in the `Meta:` section of the serialiser definition.
**Arguments**:
* `view_name` - The view name that should be used as the target of the relationship. If you're using [the standard router classes][routers] this wil be a string with the format `<modelname>-detail`. **required**.