Code Monkey home page Code Monkey logo

Comments (4)

tbarbugli avatar tbarbugli commented on May 23, 2024

Hi there,
doing celery outside of the http request is indeed a good practice. You can easily use celery for that by subclassing the default manager (https://github.com/GetStream/stream-django/blob/master/stream_django/managers.py) and change the STREAM_FEED_MANAGER_CLASS setting accordingly.

from stream-django.

isaac-peka avatar isaac-peka commented on May 23, 2024

Thanks a lot - makes sense. And a quick extra question (can create another issue if you'd prefer). In the docs you mentioned the Activity.activity_related_models fields will be used in a call to select_related to retrieve the objects. Is it possible to specify any fields to be retrieved with prefetch_related? Something like a generic Tag or Like will usually need the content_object to be retrieved alongside it.

from stream-django.

tbarbugli avatar tbarbugli commented on May 23, 2024

There is not direct support for prefetch_related but you can get it done by implementing a hook function in your enricher subclass. You can see the relevant part where the hook is looked up here: https://github.com/GetStream/stream-django/blob/master/stream_django/enrich.py#L90

If you model is called Tag you need to implement a method called fetch_tag_instances

eg.

from stream_django.enrich import Enrich

class MyEnrich(Enrich):

    def fetch_tag_instances(self, pks):
        return Tag.objects. in_bulk(pks).select_related(...).prefetch_related(...)

from stream-django.

isaac-peka avatar isaac-peka commented on May 23, 2024

Thanks a lot 👍

from stream-django.

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.