Skip to content

Commit

Permalink
Fixes conflicting collection name documentation.
Browse files Browse the repository at this point in the history
Fixes issue jfinkels#382.
  • Loading branch information
jfinkels committed Jan 12, 2015
1 parent 3fba736 commit 673e7ef
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 6 deletions.
13 changes: 9 additions & 4 deletions docs/customizing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -81,14 +81,19 @@ argument::

Then your API for ``Person`` will be available at ``/api/v2/person``.

.. _collectionname:

Collection name
~~~~~~~~~~~~~~~

By default, the name of the collection which appears in the URLs of the API
will be the name of the table which backs your model. If your model is a
SQLAlchemy model, this will be the value of ``__tablename__``. If your model is
a Flask-SQLAlchemy model, this will be the lowercase name of the model with
``CamelCase`` changed to ``camel_case``.
will be the name of the table that backs your model. If your model is a
SQLAlchemy model, this will be the value of its ``__tablename__`` attribute. If
your model is a Flask-SQLAlchemy model, this will be the lowercase name of the
model with camel case changed to all-lowercase with underscore separators. For
example, a class named ``MyModel`` implies a collection name of
``'my_model'``. Furthermore, the URL at which this collection is accessible by
default is ``/api/my_model``.

To provide a different name for the model, provide a string to the
`collection_name` keyword argument of the :meth:`APIManager.create_api`
Expand Down
5 changes: 3 additions & 2 deletions flask_restless/manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,9 @@ def create_api_blueprint(self, model, methods=READONLY_METHODS,
The endpoints for the API for ``model`` will be available at
``<url_prefix>/<collection_name>``. If `collection_name` is ``None``,
the lowercase name of the provided model class will be used instead, as
accessed by ``model.__name__``. (If any black magic was performed on
``model.__name__``, this will be reflected in the endpoint URL.)
accessed by ``model.__tablename__``. (If any black magic was performed
on ``model.__tablename__``, this will be reflected in the endpoint
URL.) For more information, see :ref:`collectionname`.
This function must be called at most once for each model for which you
wish to create a ReSTful API. Its behavior (for now) is undefined if
Expand Down

0 comments on commit 673e7ef

Please sign in to comment.