{"action":"created","issue":{"url":"https://api.github.com/repos/sabricot/django-elasticsearch-dsl/issues/132","repository_url":"https://api.github.com/repos/sabricot/django-elasticsearch-dsl","labels_url":"https://api.github.com/repos/sabricot/django-elasticsearch-dsl/issues/132/labels{/name}","comments_url":"https://api.github.com/repos/sabricot/django-elasticsearch-dsl/issues/132/comments","events_url":"https://api.github.com/repos/sabricot/django-elasticsearch-dsl/issues/132/events","html_url":"https://github.com/sabricot/django-elasticsearch-dsl/issues/132","id":362884443,"node_id":"MDU6SXNzdWUzNjI4ODQ0NDM=","number":132,"title":"DocType inheritance","user":{"login":"krelst","id":4048504,"node_id":"MDQ6VXNlcjQwNDg1MDQ=","avatar_url":"https://avatars3.githubusercontent.com/u/4048504?v=4","gravatar_id":"","url":"https://api.github.com/users/krelst","html_url":"https://github.com/krelst","followers_url":"https://api.github.com/users/krelst/followers","following_url":"https://api.github.com/users/krelst/following{/other_user}","gists_url":"https://api.github.com/users/krelst/gists{/gist_id}","starred_url":"https://api.github.com/users/krelst/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/krelst/subscriptions","organizations_url":"https://api.github.com/users/krelst/orgs","repos_url":"https://api.github.com/users/krelst/repos","events_url":"https://api.github.com/users/krelst/events{/privacy}","received_events_url":"https://api.github.com/users/krelst/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":2,"created_at":"2018-09-22T19:34:37Z","updated_at":"2018-09-23T20:00:23Z","closed_at":null,"author_association":"NONE","body":"It would be nice to be able to have a mixin with some common fields you use in every document. This way the mixin can be used to avoid having to declare the common fields on all documents. E.g. I am developing a multi-tenant application, so I would like to add the tenant id to every document.\r\n\r\nAn example:\r\n```python\r\nfrom django_elasticsearch_dsl import DocType, fields\r\n\r\nclass DefaultDocumentFieldsMixin(object):\r\n    tenant_id = fields.KeywordField()\r\n\r\n    def prepare_tenant_id(self, instance):\r\n        return get_active_tenant().id\r\n\r\nclass CarDocument(DefaultDocumentFieldsMixin, DocType):\r\n     pass\r\n```\r\nAt this moment this doesn't seem to be working, as the tenant_id is not added to any of the documents I use this mixin. Is this intended behaviour, or actually a bug? Is there another way to get to achieve the same behaviour?"},"comment":{"url":"https://api.github.com/repos/sabricot/django-elasticsearch-dsl/issues/comments/423843540","html_url":"https://github.com/sabricot/django-elasticsearch-dsl/issues/132#issuecomment-423843540","issue_url":"https://api.github.com/repos/sabricot/django-elasticsearch-dsl/issues/132","id":423843540,"node_id":"MDEyOklzc3VlQ29tbWVudDQyMzg0MzU0MA==","user":{"login":"safwanrahman","id":7114151,"node_id":"MDQ6VXNlcjcxMTQxNTE=","avatar_url":"https://avatars0.githubusercontent.com/u/7114151?v=4","gravatar_id":"","url":"https://api.github.com/users/safwanrahman","html_url":"https://github.com/safwanrahman","followers_url":"https://api.github.com/users/safwanrahman/followers","following_url":"https://api.github.com/users/safwanrahman/following{/other_user}","gists_url":"https://api.github.com/users/safwanrahman/gists{/gist_id}","starred_url":"https://api.github.com/users/safwanrahman/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/safwanrahman/subscriptions","organizations_url":"https://api.github.com/users/safwanrahman/orgs","repos_url":"https://api.github.com/users/safwanrahman/repos","events_url":"https://api.github.com/users/safwanrahman/events{/privacy}","received_events_url":"https://api.github.com/users/safwanrahman/received_events","type":"User","site_admin":false},"created_at":"2018-09-23T20:00:23Z","updated_at":"2018-09-23T20:00:23Z","author_association":"COLLABORATOR","body":"have you tried placing the mixin after the DocType class?\r\n\r\n```python\r\nclass CarDocument(DocType, DefaultDocumentFieldsMixin):\r\n     pass\r\n``"}}
{"actor":{"display_login":"safwanrahman"}}