This was a lot of trial and error, but it seems that by using importlib.import_module(module_name), we don't have to interact with the sys.modules. Instead, we just pass it a python import like "myapp.components.calendar". And so, there are no conflcts with 3rd party libraries anymore.
I wonder what would be a good way to test this:
I tried adding a django.py to one of the test_structures (e.g. tests/test_structures/test_structure_1/components/django/django.py), but it didn't get picked up.
I checked if things worked or not by having a django.py component in the sampleproject (sampleproject/components/django/django.py). That worked, but don't know if we want to use the demo project for testing.
I was thinking that maybe we could have a full django project for end-to-end tests? But didn't want to tinker with that as part of this issue. Maybe we could add that to the milesone for v1? What do you think @EmilStenstrom?
Fixes https://github.com/EmilStenstrom/django-components/issues/431
This was a lot of trial and error, but it seems that by using
importlib.import_module(module_name)
, we don't have to interact with thesys.modules
. Instead, we just pass it a python import like"myapp.components.calendar"
. And so, there are no conflcts with 3rd party libraries anymore.I wonder what would be a good way to test this:
django.py
to one of thetest_structures
(e.g.tests/test_structures/test_structure_1/components/django/django.py
), but it didn't get picked up.django.py
component in the sampleproject (sampleproject/components/django/django.py
). That worked, but don't know if we want to use the demo project for testing.