I
I
Ilya Korol2020-07-20 18:49:43
Django
Ilya Korol, 2020-07-20 18:49:43

How to import models from a Django application into a program?

There is a project bot app in Django.
In the working folder of the project there is also a run.py file.
Django project launched in production via gunicorn
How to import models from a Bot application from run.py?

Answer the question

In order to leave comments, you need to log in

2 answer(s)
I
Ilya Korol, 2020-07-20
@welcome32

import sys
import django
import project.settings as DjangoSettings

sys.path.append('path_to_project')

os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings')
django.setup()

from Bot import models

D
Dimonchik, 2020-07-20
@dimonchik2013

from bot.models import *

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question