Background information:
I would like to run the feeder.py
script using atoms script
plug-in. I first encountered a ImproperlyConfigured
error which was solved as suggested here: First fix
Then I run into RuntimeError: Model class models.AccountInformation doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.
error which was solved by using an absolute path for the model import as shown below.
Current issue:
Using the mentioned absolute import, I receive this error:
ModuleNotFoundError: No module named 'Dashboard_app'
I can even render the template for that app etc. so I am confused why he tells me that the module doesn't exist. When I remove the model import, everything works just fine. Is it maybe that the script
instance doesn't recognize it properly?
What I've tried:
__init__.py
INSTALLED-APPS
dicDASHEX.Dashboard_app.models
resulting in no module named DASHEX
errormodels
resulting in Model class models.AccountInformation doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS
errorINSTALLED_APPS
to Dashboard_app
feeder.py script:
import django
from django.conf import settings
import zmq
import time
from time import sleep
import uuid
settings.configure()
django.setup()
import sys
print(sys.path)
from Dashboard_app.models import AccountInformation
[...]
settings.py:
# Application definition
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
#other Apps
'Wiki_app',
'rest_framework',
'Dashboard_app.apps.DashboardAppConfig'
]
Models.py:
from django.db import models
import uuid
# Create your models here.
class AccountInformation(models.Model):
version = models.CharField(max_length=20, blank=False)
DID = models.UUIDField(primary_key=True, default=uuid.uuid4, editable=False)
accountNumber = models.IntegerField(blank=False)
broker = models.CharField(max_length=50, blank=False)
leverage = models.CharField(max_length=10, blank=False)
account_balance = models.FloatField(max_length=15, blank=False)
account_profit = models.FloatField(max_length=15, blank=False)
account_equity = models.FloatField(max_length=15, blank=False)
account_margin = models.FloatField(max_length=15, blank=False)
account_margin_free = models.FloatField(max_length=15, blank=False)
account_margin_leve = models.FloatField(max_length=15, blank=False)
account_currency = models.CharField(max_length=20, blank=False)
class Meta:
db_table = 'AccountInfo'
def __str__(self):
return self.accountNumber
Project structure:
I think (almost sure!) that the problem is about the settings.configure()
; as you didn't specify any default_settings
, django will use it's default settings template (the one you see when you create a new project) and your Dashboard_app
is not there. That's the cause of this error:
changed import path to models resulting in Model class models.AccountInformation doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS error
Try specifiying your settings inside the configure
:
from dashex import settings
settings.configure(settings)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.