can't restore my site back after adding allowed_hosts = ['*']

i did that already and installed it back but got nothing, so i don’t want to install bootstrap4 as i already installed these two ones in site_packages
Screenshot 2022-12-18 at 5.39.41 AM
so i have the old one still exist as i think in site packages
Screenshot 2022-12-18 at 5.39.58 AM
do i have to remove it manually cause the error is Exception in thread django-main-thread
or
i have to install it back again?
i was trying to deploy the site away of my computer to see if the Env var may affect the site or may another clear issues arise and got this bootstrap one it already been happened before and i had to reinstalled it but removed it again after clear any thing have bootstrap4

So there are two ways to fix that problem.

  • Yes, you could reinstall that particular package.

  • Or, you can remove the references to it from your project.

okay bro i am still trying to catch the problem and you really help me and encourage me to keep up
thanks a lot for you, you are the best

the problem is here in this file
File “/Library/Frameworks/Python.framework/Versions/3.10/lib/python3.10/importlib/init.py”, line 15, 126 in import_module

try:
    import _frozen_importlib as _bootstrap 
.....
.....
   return _bootstrap._gcd_import(name[level:], package, level)

it’s not clear which version or which one that python require and as it’s not django-bootstrap5 or django-bootstrap it’s only require just bootstrap and that is only exist in bootstrap folder that i just deleted so it will stay require it and i have to instal it back again, why this happens or do i am wrong ?

No, it’s even easier than that.

The problem is in your settings file.

which line exactly cause i changed this line

CRISPY_TEMPLATE_PACK = 'django-bootstrap5'

it was previously bootstrap4

Oh i found it it was in installed app
god bless you @KenWhitesell bro
accept my apologies and all blessings to you
now it can run server well but still not getting the site really miscarry situation
i will try again to debug my settings but i am really exhausted now i have to take some rest cause this issue will stay long with me

please bro suggest on me what to do in this issue
i have figured out the problem of pinax-notifications app ugettext_lazy needed for messages or post man apps locally on my pc
but as long as i added site_packages to gitignore file the digitalocean platform install it from the
requirements.txt so the deploy will fail
what should i do in this case
remove it from the requirements.txt or what cause i can’t reach to the source code on digital ocean
or remove it totally and pip freeze and push again to repo
which is best if i don’t want to remove it
ad regarding to our big problem i still can’t get my site home or other locally, i just said if i can deploy it successfully may it works on digital ocean


Screenshot 2022-12-18 at 4.27.51 PM

See the docs at GitHub - pinax/pinax-notifications: user notification management for the Django web framework

i know that it has been deprecated bro
i fix it locally so you mean it can’t be on platform using 3.10 python or django 4
anyway i have removed it from requirements.txt
and i will back to you later to tell you what happened
see you brother
thanks for everything

That’s what the package says.

If you want to use it with Django 4 / Python 3.10, then you’ll need to fork the package and create an updated version.

You might even find that someone else has forked it and already made those updates.

that’s really a good idea and that’s what i except always from you giving me a great ideas and surprises, but really i didn’t try to do this before, i already updated the repo locally but never send a pull request and as they never do anything from 2020, so it’s not guaranteed to be accepted,
in this case there is an alternative to this rather than install it as a lib or package i can pull it up from site packages as a direct django app and it would be nice idea too

I’m not necessarily suggesting you update the public repo. What you can do however is build the wheel file from the package, and install that in your virtual environment.

i will try that sure but later cause i am still trying to deploy it first and i added allowed hosts already true but i get always this error

settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

here is the latest settings

EVELOPMENT_MODE = os.getenv("DEVELOPMENT_MODE", "False") == "True"
# productions Settings
if DEVELOPMENT_MODE is True:
    DATABASES = {
    'default': {
        'ENGINE': 'django.db.backends.postgresql_psycopg2', # django.db.backends.mysql'
        'NAME': os.environ.get('PG_NAME'), # DB Name os.environ['PG_NAME'],
        'USER': os.environ.get('PG_USER'),  # os.environ['PG_USER'], from server register => connection tab change the name of server and username
        'PASSWORD': os.getenv('PG_PASSWORD'), # os.environ['PG_PASSWORD'], 
        'HOST': os.environ.get('PG_HOST'), # remotely => dj_database_url.parse(os.environ.get("PG_HOST")), 
        'PORT': os.environ.get('PG_PORT'),   # postgresql://USERNAME:PASSWORD@DB_HOST:DB_PORT/DATABASE_NAME
    },
    "test": {
        "ENGINE": "django.db.backends.sqlite3",
        "NAME": os.path.join(BASE_DIR, "db.sqlite3"),
    }
}
elif len(sys.argv) > 0 and sys.argv[1] != 'collectstatic':
    if os.getenv("DB_URL", None) is None:
        raise Exception("DATABASE_URL environment variable not defined")
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.postgresql_psycopg2', # django.db.backends.mysql'
            'NAME': os.environ.get('DB_NAME'), # DB Name os.environ['PG_NAME'],
            'USER': os.environ.get('DB_USER'),  # os.environ['PG_USER'], from server register => connection tab change the name of server and username
            'PASSWORD': os.getenv('DB_PASSWORD'), # os.environ['PG_PASSWORD'], 
            'HOST': os.environ.get('DB_URL'), # remotely => dj_database_url.parse(os.environ.get("DB_URL")), 
            'PORT': os.environ.get('DB_PORT'),   # postgresql://USERNAME:PASSWORD@DB_HOST:DB_PORT/DATABASE_NAME
        },
    }
# Update database configuration from $DATABASE_URL.
db_from_env = dj_database_url.config(conn_max_age=500)
DATABASES['default'].update(db_from_env)
# or
if "DB_URL" in os.environ:
    # Configure Django for DATABASE_URL environment variable.
    DATABASES["default"] = dj_database_url.config(conn_max_age=500, ssl_require=True)

    # Enable test database if found in CI environment.
    if "CI" in os.environ:
        DATABASES["default"]["TEST"] = DATABASES["default"]

it was alternate between the domain hosts error and engine error

Invalid HTTP_HOST header: 'starfish-app-xgsam.ondigitalocean.app'. You may need to add 'starfish-app-xgsam.ondigitalocean.app' to ALLOWED_HOSTS.
settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.

Your allowed hosts entry has nothing to do with this.

You’ve got something else wrong with how you have your databases configured - or how you have the environment variables defined.

The easiest way to demonstrate that is to code the settings directly into the settings file.

Also, see Databases | Django documentation | Django

i am on production bro, so i can’t push upmy credintials in git hub i have set the allowed hosets like that
in settings.py

ALLOWED_HOSTS = os.getenv("ALLOWED_HOSTS", "localhost").split(",")

and in env

ALLOWED_HOSTS=starfish-app-xgsam.ondigitalocean.app,nagy.heroku.com,127.0.0.1,localhost

so there are nothing more than these and the above settings should work fine in digitalocean
also the error is mentioning that i have to supply engine value and it’s nothing else as this picture tell

i will look on the documentation you have provided to see if there is something useful , thanks bro

would you tell me please bro
is this engine

'ENGINE': 'django.db.backends.postgresql_psycopg2',

compatible with rds postgresql
or it causing this fails in digital ocean?
cause the documentations you have given me says that engine is
'ENGINE': 'django.db.backends.postgresql',
and i am using the first one locally so it may never work remotely
what do you think??

What does the docs that I pointed you to say?

i have changed the engine to the one you have provided in docs but the same issue
anyway i raised this ticket to digitalocean team to see what they will say may they connect me lol
anyway i will back to you brother
thanks so much dear brother @KenWhitesell