Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mitigate model load order issue #37

Open
radiac opened this issue Oct 1, 2024 · 0 comments
Open

Mitigate model load order issue #37

radiac opened this issue Oct 1, 2024 · 0 comments

Comments

@radiac
Copy link
Owner

radiac commented Oct 1, 2024

At the moment Django() needs to be instantiated before models can be defined (it configures settings and sets up apps). This causes problems for import order of models in other apps.

Ultimately nanodjango is making Django do something it doesn't want to do, so this project will always have limitations. However, this feels like something that I should try harder to address, as it's unexpected and causing problems (see #34)

My idea to solve this is having import nanodjango replace django.db.models.Model with a placeholder that logs subclasses but doesn't initialise them - then swap it out for the proper Model when Django() has run, and initialise the classes then. This is going to be fun, and also a crime against python.

If it works, we're still going to need to get import nanodjango in before any other apps, but that feels a nicer more solveable/manageable problem than putting Django() before the imports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Ready
Development

No branches or pull requests

1 participant