2👍
This is from Django Docs.
You must define or import all models in your application’s models.py
or models/__init__.py
. Otherwise, the application registry may not be fully populated at this point, which could cause the ORM to malfunction.
Once this stage completes, APIs that operate on models such as get_model()
become usable.
https://docs.djangoproject.com/en/3.2/ref/applications/#how-applications-are-loaded
👤Ram
-1👍
Finally I got the solution from my own. Many peoples get into this problem I saw around me.
Here how I solved the problem:
project-name/
...project-name/
...apps1/
.....models.py
...apps2/
.....models.py
...manage.py
Just the basic django project structure.
Now to import the models of apps1 into apps2:
In apps2/models.py
:
from apps1 import models as apps1Model
# Now accessing the models
apps1Model.Model1
apps1Model.Model2
- [Answered ]-Django – Javascript – Disable cache on image refresh
- [Answered ]-Python logger not working for django with apache
- [Answered ]-How to use werkzeug debugger in dotcloud?
- [Answered ]-Cannot set up Oracle bucket for django static files storage
Source:stackexchange.com