---
title: "Session: How to Customize Collection Assignment for Entities"
url: "https://docs.ravendb.net/6.2/client-api/session/configuration/how-to-customize-collection-assignment-for-entities"
version: "6.2"
language: "python"
---

# Session: How to Customize Collection Assignment for Entities

> Client language: Python. Also available for [C#](https://docs.ravendb.net/6.2/client-api/session/configuration/how-to-customize-collection-assignment-for-entities.md), [Java](https://docs.ravendb.net/6.2/client-api/session/configuration/how-to-customize-collection-assignment-for-entities.java.md), [PHP](https://docs.ravendb.net/6.2/client-api/session/configuration/how-to-customize-collection-assignment-for-entities.php.md), [Node.js](https://docs.ravendb.net/6.2/client-api/session/configuration/how-to-customize-collection-assignment-for-entities.nodejs.md).
>
> RavenDB publishes an official agent skill for coding assistants at https://docs.ravendb.net/skills/ravendb/SKILL.md (also installable with `npx skills add ravendb/skills`). The skill describes itself as: "Read this before writing any RavenDB query, client call or /databases/ request. Covers server setup, document modelling, the Node.js, .NET and Python clients, RQL, indexes, vector search and AI agents. Code written from recall tends to run and return the wrong rows, because RQL resembles SQL and the clients take field names as plain strings."

Entities are grouped into [collections](https://docs.ravendb.net/6.2/client-api/faq/what-is-a-collection.md) on the server side.  
The name of the collection that an entity belongs to can be retrieved using the `find_collection_name` convention.

## Example

By default, a collection name is the pluralized form of a name of an entity type.  
E.g., objects of type `Category` will belong to the `Categories` collection.  
If you mean to classify them as `ProductGroups`, however, use the following code:

```python
def __find_collection_name(object_type: type) -> str:
  if issubclass(object_type, Category):
      return "ProductGroups"

  return DocumentConventions.default_get_collection_name(object_type)

store.conventions.find_collection_name = __find_collection_name
```

This can become very useful when there is a need to deal with [polymorphic data](https://docs.ravendb.net/6.2/indexes/indexing-polymorphic-data.python.md).

## See also

- [Conventions](https://docs.ravendb.net/6.2/client-api/configuration/conventions.md)
- [How to Customize ID Generation for Entities](https://docs.ravendb.net/6.2/client-api/session/configuration/how-to-customize-id-generation-for-entities.md)
- [How to Customize the Identity Property Lookup for Entities](https://docs.ravendb.net/6.2/client-api/session/configuration/how-to-customize-identity-property-lookup-for-entities.md)
- [What is a Collection?](https://docs.ravendb.net/6.2/client-api/faq/what-is-a-collection.md)
