collectstatic deploy problem

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/", 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/
Error while running '$ python 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
failed to build: exit status 1
For documentation on the buildpacks used to build your app, please see:
Python v1.221.4
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

What version of Django are you using?

See Django 4.0 release notes | Django documentation | Django

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 was causing this error before but i changed the lines causing error already and it became

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 !!!

Finally i got the solution bro
Digital Ocean underlying are using the Heroku Buildpack
so to not make it run this command when deploying

python collectstatic --noinput

To not make Heroku run collectstatic on my behalf
i must put the env var


appreciated you bro and see you in the next bug
greeting to you :kissing_heart: :smiling_face_with_three_hearts:

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

How are you setting this variable and then how are you running your project?

Please show all the commands you’re running to do this.

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
i just run the site using the normal command
python3 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

i have changed the code in these two lines

elif len(sys.argv) > 0 and sys.argv[1] != 'collectstatic':
    if os.getenv("DATABASE_URL", None) is not None:

and i got this error
regarding to this line

"default": dj_database_url.parse(os.environ.get("DATABASE_URL")),

error", line 259, in <module>
    "default": dj_database_url.parse(os.environ.get("DATABASE_URL")),
  File "/Users/abunagy/Projects/mysite/lib/python3.10/site-packages/", 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.

Ahha okay bother really i thank god that i know you
appreciated really
i will keep up and try to continue deploy to see what is the net problem

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.

First, a side note:

As written, that if statement will never be true.

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_URL is None, which is not what I think you’re looking for.

Regarding any other environment variables, you say you’re running python 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")
        "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

pip install python-dotenv
then in put the following before any kind of env methods
from dotenv import load_dotenv