Thursday, July 25, 2019

Defining Models outside models.py

Hi everyone,

I know there are currently 3 ways to define a model in Django
1) Define it directly in the models.py file
2) Define it directly in a models package in the same directory as your other app files
3) Define it somewhere completely different and just import the models into the models.py

My question is, is there a way to write a model in any arbitrary file in you directory and link it to your app without having to use models.py file or directory.
For example is there a way to write a model directly in the views file and then add some config to the settings or elsewhere to enable Django to know of it's existence and pick up any changes that happen to it.
I don't mind if it's a complete hack
Thanks

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/95f073eb-8309-4454-8cfd-b190dde90cef%40googlegroups.com.

No comments:

Post a Comment