it’s my first time to deploy any website and i am trying to deploy my profile website on digital ocean as i got credit for free but i don’t know if anyone can help me on this error cause i got this when deploy trying to collect static I got this bug error log message
File "/app/.heroku/python/lib/python3.10/site-packages/pinax/notifications/apps.py", line 2, in
from django.utils.translation import ugettext_lazy as _
ImportError: cannot import name 'ugettext_lazy' from 'django.utils.translation' (/app/.heroku/python/lib/python3.10/site-packages/django/utils/translation/__init__.py)
Error while running '$ python manage.py collectstatic --noinput'.
See traceback above for details.
You may need to update application code to resolve this error.
Or, you can disable collectstatic for this application:
$ heroku config:set DISABLE_COLLECTSTATIC=1
https://devcenter.heroku.com/articles/django-assets
failed to build: exit status 1
For documentation on the buildpacks used to build your app, please see:
Python v1.221.4 https://do.co/apps-buildpack-python
build failed
also i pushed the repo on gethub without site_packages or bin or include folders, just the requirements.txt that tell digitalocean app platform what is the packages required for building and i don’t know where from i get heroku log as i was trying to deploy to heroku but canceled all build commands, but i still get heroku log as i am deploying to heroku why this happen and how can i fix, forgive me on my dummy question
it’s Django==4.0.5 as in my requirements.txt i already know that ugettext_lazy has been removed and this pinax message and notification app wascausing this error before but i changed the lines causing error already and it became pinax.notifications.apps.py
from django.apps import AppConfig as BaseAppConfig
from django.utils.translation import gettext_lazy as _
from django.utils.translation import gettext as _
class AppConfig(BaseAppConfig):
name = "pinax.notifications"
label = "pinax_notifications"
verbose_name = _("Pinax Notifications")
so no anymore ugettext_lazy so i don’t know from where it comes app/.heroku or why he see ugettext while there are no any ones !!!
Side note #1: Please stop bolding the majority of your text. It doesn’t help the readability of your messages.
Side note #2: You have:
Once everything else is working properly, the second line “overrides” the first. Using _ as a function name will only call gettext. There is no situation where you will be using gettext_lazy.
i was trying both ones but i just leave one only and just gave you what i have added along side all the pinax
and okey i will not bolding text , i thought that make you read clearer but as you wish bro
i don’t understand what you mean by
how are you setting this variable
i just provide it above it was written in .env variables file i have tried both of the above ones but not working i don’t know why
also
i just run the site using the normal command
python3 manage.py runserver
it was working before correctly as the short ENV variable but faild to connect so i provide the full one with credintials
the coonection string that i got is from the aws rds security & connectivity tab
all these settings is not mine i get it from the digital ocean platform that i deploy my site on
settings.py", line 259, in <module>
"default": dj_database_url.parse(os.environ.get("DATABASE_URL")),
File "/Users/abunagy/Projects/mysite/lib/python3.10/site-packages/dj_database_url.py", line 80, in parse
if '?' in path and not url.query:
TypeError: a bytes-like object is required, not 'str'
that mean it now see the ENV Var but it require it to not be a str , so how to put it as a byte like object
i can’t write the DATABASE_URL as an object like key:val , i didn’t know i think that is not correct
.env files don’t automatically set environment variables. If you’re running this locally, you either need to set the environment directly, or use a module that loads a .env file into the environment.
but how come bro it reads the other variables !!!
i didn’t get that really cause it read it already after changing the line of code, anyway i will try another think
thanks anyway for help
I can’t answer your question because you’re not giving me complete information about what you’re doing.
What does the rest of your settings file look like?
The issue with you just posting snippets of code that you think are most relevent is that you’re cutting out information that would be helpful. When you try to summarize things, it leaves us in a position of having to try and guess the missing information.
Actual code and file contents are a lot more useful than just a verbal description of the contents of those files.
This line: DEVELOPMENT_MODE = os.getenv("DEVELOPMENT_MODE", "False") == "True"
is going to result in DEVELOPMENT_MODE either being True or False, it will never be dev
This if statement is going to be True if the environment variable DATABASE_URL is not None, in which case it’s going to throw an exception.
This means that the DATABASES setting will be calling dj_database_url only if DATABASE_URLis None, which is not what I think you’re looking for.
Regarding any other environment variables, you say you’re running python manage.py runserver from the command line. You should check your local environment to see what Django-related environment variables may be set in your current environment.
it was True rather than dev but i changed it to try changing the Env var DEVELOPMENT_MODE
but you are true the problem is is in this line
if os.getenv("DATABASE_URL", None) is not None:
raise Exception("DATABASE_URL environment variable not defined")
DATABASES = {
"default": dj_database_url.parse(os.environ.get("DATABASE_URL")),
i will check again bro and understand and back to you
apreciate your efforts really to help me
god bless you