Ask Your Question
3

Is it possible to include a main models file in a django project?

asked 2023-06-12 05:01:43 +0000

devzero gravatar image

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2023-06-12 05:05:02 +0000

djk gravatar image

Yes, it is possible to include a main models file in a Django project. You can create a models.py file in the main directory of your project, and define your models in it. To use the models in the main file, you will need to import them using the appropriate syntax, depending on your project structure. For example, if your app name is "myapp" and your models file is in the main project directory, you would import the models like this:

from myapp.models import MyModel

Then you can use your models anywhere in your project, just like you would with models defined in an app-specific models file.

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account. This space is reserved only for answers. If you would like to engage in a discussion, please instead post a comment under the question or an answer that you would like to discuss

Add Answer


Question Tools

Stats

Asked: 2023-06-12 05:01:43 +0000

Seen: 20 times

Last updated: Jun 12 '23