I’m using Django 5.0.1 version, where i want to maintain my lot of models into separate folders with some sub-folders into the django project app.
so, how to make accessible to models of that different folders to do “makemigrations”?
I tried init.py by adding “from .models import models” but not working working.
I tried lot of things including chatgpt, Bingchat & more… but still not able to firgure out solution?
Please anyone help me.
I suggest you don’t - it’s really not worth the effort.
You’re going to save yourself a number of potential problems by not trying to do this.
If you think you have a situtation where you need to do this, please describe the situation and we might be able to propose a solution.
But Django has its own strongly-held opinions as to how your project should be structured, and trying to change that without fully understanding all of the implications can be a major headache.
Thanks for your response.
actually in my django app, i have 251 models into single models.py so i want to separate some models into folders & files, so it will be easy to recognize models quickly for developers!
That’s a case where I’d recommend splitting these models out into different apps.
ok got it, if i create at least 150 apps then is there performance issue?
Not 150 apps. 250 models probably cleanly divides into somewhere between 5 and 8 apps.
Do your developers a favor, do not try to go to one model per file. (Actually, there’s another post around here where I’ve addressed this topic before.)
See my comment at categorizing models in own files instead of models.py - #6 by KenWhitesell
You will never convince me that there’s anything to be gained - and a lot lost - by going with more files rather than fewer.
Amazing, Thanks @KenWhitesell