my project was old python now using python 3 where do i start ?
when i run python3 manage.py or add runserver etc i get
python manage.py runsever
[‘/home/nt1506/NOC-Central/noc-central/noc-central’, ‘/home/nt1506/.pyenv/versions/3.9.7/lib/python39.zip’, ‘/home/nt1506/.pyenv/versions/3.9.7/lib/python3.9’, ‘/home/nt1506/.pyenv/versions/3.9.7/lib/python3.9/lib-dynload’, ‘/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages’, ‘/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages/noc-1.0-py3.9.egg’]
Traceback (most recent call last):
File “/home/nt1506/NOC-Central/noc-central/noc-central/manage.py”, line 13, in
from noc.apps.rancidmanager.models import InstallationParameter
File “/home/nt1506/NOC-Central/noc-central/noc-central/noc/apps/rancidmanager/models.py”, line 2, in
from noc.apps.platformprovisioningtool.models import InstallationParameter
File “/home/nt1506/NOC-Central/noc-central/noc-central/noc/apps/platformprovisioningtool/models.py”, line 24, in
class InstallationOutput(models.Model):
File “/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages/django/db/models/base.py”, line 129, in new
app_config = apps.get_containing_app_config(module)
File “/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages/django/apps/registry.py”, line 260, in get_containing_app_config
self.check_apps_ready()
File “/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages/django/apps/registry.py”, line 137, in check_apps_ready
settings.INSTALLED_APPS
File “/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages/django/conf/init.py”, line 102, in getattr
self._setup(name)
File “/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages/django/conf/init.py”, line 89, in _setup
self._wrapped = Settings(settings_module)
File “/home/nt1506/NOC-Central/noc-central/noc-central/venv/lib/python3.9/site-packages/django/conf/init.py”, line 271, in init
raise ImproperlyConfigured(
django.core.exceptions.ImproperlyConfigured: DEFAULT_FILE_STORAGE/STORAGES are mutually exclusive.
please help i am stuck
The key information about this error is on the very last line. What do you think this error is telling you?
it is suggesting to choose one either storage/storage_default_file
i dont see where is this file to located , it is a old project, i cant remember the file name , i used grep -rl with that error in the Noc dir , i dont see anywhere hence why i wanted help by an expert?
These are configuration settings in your settings.py file. Look for the two entries shown in the error message. See DEFAULT_FILE_STORAGE and STORAGES
I dont have the file settings.py rather base.py and local.py
Ok, whatever - it’s in the file(s) where your settings are.
can give the content ? it wasnt there i added it after the encoutered that errorr
I don’t understand your question.
cant share the content of the code? and I am saying the storage div was added by me when I encountered that error.
hence why i said i dont see where it was located at first.
my big problem is to locate where storage file is setup … you mentioned usually in settings.py i dont have, I have local.py in settings directory
The name of the file for the settings isn’t important - you can make it whatever you want.
What’s important are the contents of that file.
Look for those two entries in whatever file it is that you are storing your settings in.
thanks. it seems i dont have that setup, could i have a sample guide of how it has to be ?
Please post the contents of your settings files and of your manage.py file.
thanks:
manage.py
import os
import sys
import django
from django.core.management import execute_from_command_line
if __name__ == "__main__":
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "noc.settings.local")
print(sys.path)
# Use django.setup() to set up the application registry
# django.setup()
from noc.apps.rancidmanager.models import InstallationParameter
execute_from_command_line(sys.argv)
TEMPLATE_DEBUG = DEBUG
ADMINS = (
('Howard Jones', 'howard.jones@virtustream.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'noc',
'USER': 'noc',
'PASSWORD': 'flfllfb',
'HOST': '127.0.0.1', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
'PORT': '', # Set to empty string for default.
}
}
}
}
ROOT_URLCONF = 'noc.urls.local'
WSGI_APPLICATION = 'noc.wsgi.local.application'
and this is my base.py
"""Base settings shared by all environments"""
# Import global settings to make it easier to extend settings.
from django.conf.global_settings import * # pylint: disable=W0614,W0401
#==============================================================================
# Generic Django project settings
#==============================================================================
DEBUG = True
TEMPLATE_DEBUG = DEBUG
SITE_ID = 1
# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
TIME_ZONE = 'UTC'
USE_TZ = True
USE_I18N = True
USE_L10N = True
LANGUAGE_CODE = 'en'
LANGUAGES = (
('en', 'English'),
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = '5+0te&ctq#q@4t6s^04$4215zljs^db%qhu)fy&75=$5)6mmng'
INSTALLED_APPS = (
'noc.apps.frontpage',
'noc.apps.oui',
'noc.apps.routehole',
'noc.apps.nocdisplay',
'noc.apps.platformprovisioningtool',
'noc.apps.rancidmanager',
'noc.apps.autodoc',
'noc.apps.passwordstore',
# 'south',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.humanize',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.admin',
'django.contrib.admindocs',
)
#==============================================================================
# Calculation of directories relative to the project module location
#==============================================================================
import os
import sys
import noc as project_module
PROJECT_DIR = os.path.dirname(os.path.realpath(project_module.__file__))
PYTHON_BIN = os.path.dirname(sys.executable)
ve_path = os.path.dirname(os.path.dirname(os.path.dirname(PROJECT_DIR)))
# Assume that the presence of 'activate_this.py' in the python bin/
# directory means that we're running in a virtual environment.
if os.path.exists(os.path.join(PYTHON_BIN, 'activate_this.py')):
# We're running with a virtualenv python executable.
VAR_ROOT = os.path.join(os.path.dirname(PYTHON_BIN), 'var')
elif ve_path and os.path.exists(os.path.join(ve_path, 'bin',
'activate_this.py')):
# We're running in [virtualenv_root]/src/[project_name].
VAR_ROOT = os.path.join(ve_path, 'var')
else:
# Set the variable root to a path in the project which is
# ignored by the repository.
VAR_ROOT = os.path.join(PROJECT_DIR, 'var')
if not os.path.exists(VAR_ROOT):
os.mkdir(VAR_ROOT)
#==============================================================================
# Project URLS and media settings
#==============================================================================
ROOT_URLCONF = 'noc.urls'
LOGIN_URL = '/login/'
LOGOUT_URL = '/logout/'
LOGIN_REDIRECT_URL = '/'
STATIC_URL = '/static/'
MEDIA_URL = '/uploads/'
STATIC_ROOT = os.path.join(VAR_ROOT, 'static')
MEDIA_ROOT = os.path.join(VAR_ROOT, 'uploads')
STATICFILES_DIRS = (
os.path.join(PROJECT_DIR, 'static'),
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.FileSystemFinder',
)
#==============================================================================
# Templates
#==============================================================================
TEMPLATE_DIRS = (
os.path.join(PROJECT_DIR, 'templates'),
)
TEMPLATES[0]['OPTIONS']['context_processors'] += [
'django.contrib.auth.context_processors.auth',
'django.template.context_processors.debug',
'django.template.context_processors.i18n',
'django.template.context_processors.media',
'django.template.context_processors.static',
'django.template.context_processors.tz',
'django.contrib.messages.context_processors.messages',
]
#==============================================================================
# Middleware
#==============================================================================
MIDDLEWARE_CLASSES += (
)
#==============================================================================
# Auth / security
#==============================================================================
AUTHENTICATION_BACKENDS += (
)
#==============================================================================
# Miscellaneous project settings
#==============================================================================
#==============================================================================
# Third party app settings
What is this?
(What is the InstallationParameter
in the that file?)
Note: You should not have this line:
Quoting directly from the docs at Django settings | Django documentation | Django
Note that a settings file should not import from global_settings
, because that’s redundant.
Thinking about this some more, what I would recommend is that you get a known-good settings file (perhaps the one created by “startproject”, and change it to add your specific requirements here for this environment. Then, once you’ve validated the settings, go ahead and recreate the structure your using now, starting from that validated base.
thank you I will revert back tomorrow it is midnight here thank you so so much o far
Hi dear,
where do i define my storage and how to reference it ? any links or doc ?
The docs are in the links above at error when running manage.py migrate - #4 by KenWhitesell
The definitions belong in your settings file.