Tutor plugin to hook Django signals


I am playing with plugins in tutor, and I want to create a receiver for Django Signals. At this point everything is fine, the problem comes because I do not know where to connect my plugin entry point together with the hook.

I have created a python package, and I can install it using tutor into Open edX -it seems it works-, but I have a receiver to hook the Django signal -with some dummy logic- and I do not know how to install/setup into Open edX, or where it should be declared into Open edX… when I understand how it should be integrated I guess I will understand how to modify the plugin (patch, hook,…) I have just created.

Any help is welcomed, thanks!

As far as I understood your question, signals are setup in same way as we are doing in any simple django app in signal.py but If you want recieve some openedx event like course updated, published then event name is different otherwise for normal django model it’s same.

Let me know, I understood it correctly.

Where does your plugin entry point live? In a separate Python package? Is it a reusable Django application? It should; then I believe all you have to do is to add it to your INSTALLED_APPS in the LMS (or the CMS).

Yes, It is separate django app and add it as git submodule in edx and yes, put entry in installed_apps

Thanks both for the reply. My entry point is a hook in the init of LMS - Open edX where I have to decide how to modify the docker-image to add MySignalsApp. At this point, I have a tutor-plugin in one hand, and my-app to control Django Signals in another, how to put both together? Not sure how should I do it.

It looks like you are conflating two very different things here:

  1. You should use a Tutor patch to install your re-usable application in the Docker container. You should probably have a “openedx-dockerfile” patch with the following content: RUN pip install myreusableapp. Then you will need to re-build the openedx Docker image (tutor images build openedx).

  2. To add the reusable app to the LMS, you should add its name to the list of INSTALLED_APPS. To do so, you should again use a Tutor patch – probably the “openedx-lms-common-settings” patch, where you will write: INSTALLED_APPS.append("myreusableapp").

Does that make sense?


Yep! It makes sense, thanks so much. I will come back with the results, I really appreciate your help (both)

Yes Make sense. Above link giving same detail to set custom code.

1 Like

To add the reusable app to the LMS, you should add its name to the list of INSTALLED_APPS. To do so, you should again use a Tutor patch – probably the “openedx-lms-common-settings” patch, where you will write: INSTALLED_APPS.append("myreusableapp") .

You can actually use the plugin system for this step to automatically install the djangoapp [1]. It also reference signals in the README, so it could maybe help you installing the signals (Many options are optional, as an example, here is an app that is installed only with the pip install step [2][3]).


[1] https://github.com/edx/edx-django-utils/tree/master/edx_django_utils/plugins
[2] https://github.com/eol-uchile/eol_completion/blob/master/setup.py#L17
[3] https://github.com/eol-uchile/eol_completion/blob/master/eol_completion/apps.py#L8


Yes, this is actually a better solution. Thanks for pointing this out. (Felipe is referring to the Open edX plugin system, totally unrelated with the Tutor plugin system)

I come back to give you thanks for your help! In the end, it was easier for me going from the Django app approach, updating manually the INSTALLED_APP settings. It works like a charm! One only trick: as I need to install a local python package into the tutor-openedx system, I run a script as follow:

1. Update tutor plugin, contains patches to install my Django App (python package):

  • pip install <local_path_tutor_plugin>
  • tutor plugins enable <tutor_plugin>
  • tutor config save

2. Move python package (django app) into Open edX (tutor system)

  • mkdir “$(tutor config printroot)/env/build/openedx/plugins”
  • cp -R django-apps/<python_package> “$(tutor config printroot)/env/build/openedx/plugins/”

3. Re-create the Open edX image with my Django app installed

  • tutor images build openedx

As you can guess, my tutor plugin, will RUN pip install pointing to “/openedx/plugins/<python_package>”

I’m glad you figured it out @miguelangel-dev. Regarding step 2, are you aware of this section in the docs? https://docs.tutor.overhang.io/configuration.html#installing-extra-xblocks-and-requirements

I don’t understand step1. can u talk clearly this? which is the local_path_tutor_plugin?