Giter Site home page Giter Site logo

[BUG] Can't override get_queryset method when using ObserverModelInstanceMixin and GenericAsyncAPIConsumer about djangochannelsrestframework HOT 3 OPEN

erdos4d avatar erdos4d commented on June 12, 2024
[BUG] Can't override get_queryset method when using ObserverModelInstanceMixin and GenericAsyncAPIConsumer

from djangochannelsrestframework.

Comments (3)

hishnash avatar hishnash commented on June 12, 2024

Hi @erdos4d thank you for reporting this you should absolutly be able to override the get_queryset method... through in my examples I tend to use fitler_queryset (that should work)

just to be clear the intention here is to filter what a user can subscribe to ? or is the intention to filter the results from REST like actions: list retrieve create and update etc?

from djangochannelsrestframework.

hishnash avatar hishnash commented on June 12, 2024

So I have done a little more looking into this and the source of the issue is

The reason this is here is we need to register a django even hook on the database record. (this needs to happen before any insurance of the consumer is created but rather when django starts up) so we cant use get_queryset as this is an instance method and we need to be able to know the DB record type at django startup to register change handlers on all running threads/instrances of django.

you can use filter_queryset method (as used here https://nilcoalescing.com/blog/BuildingARealtimeSocialNetworkUsingDjangoChannels/#websocket-consumer ) to filter based on the user (however as that post describes this has limited use for subscription in that case you need to follow the suggestions in the post by defining the groups that are used to notify of changes and limiting what groups a user can subscribe to).

from djangochannelsrestframework.

hishnash avatar hishnash commented on June 12, 2024

this mixin should realy check if get_queryset has been defined and if it has it should raise some warning.

from djangochannelsrestframework.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.