{"action":"created","issue":{"url":"https://api.github.com/repos/r4fek/django-cassandra-engine/issues/66","repository_url":"https://api.github.com/repos/r4fek/django-cassandra-engine","labels_url":"https://api.github.com/repos/r4fek/django-cassandra-engine/issues/66/labels{/name}","comments_url":"https://api.github.com/repos/r4fek/django-cassandra-engine/issues/66/comments","events_url":"https://api.github.com/repos/r4fek/django-cassandra-engine/issues/66/events","html_url":"https://github.com/r4fek/django-cassandra-engine/pull/66","id":159629942,"number":66,"title":"_meta api support","user":{"login":"richardasaurus","id":2279659,"avatar_url":"https://avatars.githubusercontent.com/u/2279659?v=3","gravatar_id":"","url":"https://api.github.com/users/richardasaurus","html_url":"https://github.com/richardasaurus","followers_url":"https://api.github.com/users/richardasaurus/followers","following_url":"https://api.github.com/users/richardasaurus/following{/other_user}","gists_url":"https://api.github.com/users/richardasaurus/gists{/gist_id}","starred_url":"https://api.github.com/users/richardasaurus/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/richardasaurus/subscriptions","organizations_url":"https://api.github.com/users/richardasaurus/orgs","repos_url":"https://api.github.com/users/richardasaurus/repos","events_url":"https://api.github.com/users/richardasaurus/events{/privacy}","received_events_url":"https://api.github.com/users/richardasaurus/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":10,"created_at":"2016-06-10T13:00:17Z","updated_at":"2016-06-13T20:24:51Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/r4fek/django-cassandra-engine/pulls/66","html_url":"https://github.com/r4fek/django-cassandra-engine/pull/66","diff_url":"https://github.com/r4fek/django-cassandra-engine/pull/66.diff","patch_url":"https://github.com/r4fek/django-cassandra-engine/pull/66.patch"},"body":"#### Relates to issue #24 \r\n\r\n- I've copied over the model_meta tests from the django repo into here and added a Cassandra model to the tests, all those tests pass. Also extra tests in `testproject/common/`.\r\n- The main _meta api is in `DjangoCassandraOptions`.\r\n- With this change the Django Cassandra models also register, so you can do `from django.apps import apps; apps.get_models()` and they'll be listed.\r\n\r\n- This alters support to be for just django 1.9+, reason being the model_meta tests include code that's 1.9+ only. \r\nIf support for 1.8 is important its simple enough to do,  we'd just need separate model_meta tests for pre and post django 1.9 in the testproject/ dir. \r\n1.7 support is not possible as _meta api was added in version 1.8.\r\n\r\n#### Important stuff:\r\n\r\n1. Because lots of django plugins call the orm like `MyModel.objects.get(pk='some-pk-value')`, I've had to make that work obviously to return a model instance. \r\nHowever you can have multiple PKs with cassandra. So with this change it would just use the first primary key column it came across (https://github.com/r4fek/django-cassandra-engine/pull/64/files#diff-4e992168e50103b71012df0b8e9a7430R417). Open to suggestions how to improve that obviously.\r\n\r\n    `MyModel._meta.pk` can also expect to be called to get the primary key field in Django, and for this also we would return the first primary key.\r\n     \r\n2. This change adds an optional Django setting variable. `CASSANDRA_FALLBACK_ORDER_BY_PYTHON`. \r\nIf set to `True` and you were to call `queryset.order_by('some_col')`, with 'some_col' being a column which python-driver raises on saying it cannot be ordered by. \r\nThen that queryset will be ordered using python as a fallback. \r\nThe idea behind this is it that it can be enabled if you install a plugin which attempts to order on something which cassandra cannot possibly do. \r\nOnce ordered by python, the queryset type returned will be `ReadOnlyDjangoCassandraQuerySet` rather than `DjangoCassandraQuerySet`.\r\n\r\n    If this setting is not set at all or set to `False`, then python-driver will raise as usual.\r\n\r\n3. Tested with the following django extensions so far, working. (If people could test with more that would be helpful)\r\n     - djangorestframework==3.3.3\r\n     - django-haystack==2.5.dev1\r\n\r\nTODO:\r\n- Documentation\r\n   \r\n"},"comment":{"url":"https://api.github.com/repos/r4fek/django-cassandra-engine/issues/comments/225697380","html_url":"https://github.com/r4fek/django-cassandra-engine/pull/66#issuecomment-225697380","issue_url":"https://api.github.com/repos/r4fek/django-cassandra-engine/issues/66","id":225697380,"user":{"login":"grillazz","id":3415861,"avatar_url":"https://avatars.githubusercontent.com/u/3415861?v=3","gravatar_id":"","url":"https://api.github.com/users/grillazz","html_url":"https://github.com/grillazz","followers_url":"https://api.github.com/users/grillazz/followers","following_url":"https://api.github.com/users/grillazz/following{/other_user}","gists_url":"https://api.github.com/users/grillazz/gists{/gist_id}","starred_url":"https://api.github.com/users/grillazz/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/grillazz/subscriptions","organizations_url":"https://api.github.com/users/grillazz/orgs","repos_url":"https://api.github.com/users/grillazz/repos","events_url":"https://api.github.com/users/grillazz/events{/privacy}","received_events_url":"https://api.github.com/users/grillazz/received_events","type":"User","site_admin":false},"created_at":"2016-06-13T20:24:51Z","updated_at":"2016-06-13T20:24:51Z","body":"@richardasaurus that is wired by same err is back when I added `permission_classes = (IsAuthenticated,)` to `ListCreateAPIView`"}}
{"actor":{"display_login":"grillazz"}}