Heroku release fails, error related to django.utils - python

So I updated my python code to Django 4.0 and with that, had to remove and update some deprecated code as "ungettext_lazy" and similar.
Locally, the code is compiling well but when I push it to heroku, I get this error:
from django.utils.translation import ungettext_lazy
ImportError: cannot import name 'ungettext_lazy' from 'django.utils.translation' (/app/.heroku/python/lib/python3.9/site-packages/django/utils/translation/__init__.py)
I've tried a few things but haven't been able to update this on heroku.

Basically solved it by removing the django-url-filter lib as it's not supporting django 4.0. Since I only used it for a small piece of code, it was better to remove it.

I solved this issue by swaping manually on requirements.txt Django==4.1 to Django==3.2.

Related

Fixing broken django module that was installed from pip, where is the code?

I have been trying to use the django-visits module, though I seem to not even get this to run cause the minute I follow the instructions for just adding it to my application here:
https://bitbucket.org/jespino/django-visits/src/c3ac83b91969?at=default
It gives me an error when I try to run server:
ERRORS:
visits.Visit.ip_address: (fields.E900) IPAddressField has been removed
except for support in historical migrations.
HINT: Use GenericIPAddressField instead.
Their hint was helpful enough, but I have no idea where pip instaleld my django-visits to where I can change the model code of this module to fix the IPAdressField
Am I approaching solving this error wrong? Should I not be looking for the original code that was installed somewhere on my machine? Do I need to somehow install this from source and not use Pip since I have to change the models.py in this module?
(I am trying to make this work on my OS X machine but ultimately will need to get this to work on CentOS box). Also the database is postgres/postgis

ImportError: No module named locallibrary.settings

You could have seen the question so many times.
But unluckily I cant solve this error.
I am using python 2.7.12 , django 1.8
The tutorial source I learn is Mozilla django development where they teach with latest version of python3 and django 1.10
Somehow I tackled to use with older version.
everything was going good until I started to import models to admin.
soem class codes started showing that it has no object member, even though it exist
and hence I finally got the error as
"ImportError: No module named locallibrary.settings"
Here what I tried:
Updated to python 3(thought that could be the problem)
appended correct sys path() with project path.
Still same error showing up
Anybody help me out for solving the issue.
If you are trying to import the settings of your project, try importing
from django.conf import settings

django-1.10 still contains deprecated and removed features

I am trying to run an existing django app. The app has been built in django-1.10. I set up a new virtualenv and installed the requirements and everything. However, I get errors like the following:
from django.utils import importlib
ImportError: cannot import name importlib
Now, the above is from the following source - .virtualenvs/crowd/lib/python2.7/site-packages/account/conf.py
When I manually fix the conf.py file, I still keep getting errors to fix either deprecated or removed features from older django versions.
Any idea as to how to fix this? I thought the purpose of working in virtualenvs was to avoid such errors.
Any suggestions would be much appreciated. Thanks in advance!
This is how the question is different: Even after I fix the importlib import statement, it keeps giving me errors like that of the usage of SubFieldBase and so on.
The problem was not with the Django-core but with django-user-accounts app that was included with pinax. Upgrading the django-user-accounts app fixed the issue.
Thanks to #Selcuk for the solution.

Should I stop using a deprecated module?

I am using django-registration v0.7 and django 1.2.4. Everything works fine but I am wondering why I'm getting this warning message each time I run the server:
C:\Python26\lib\site-packages\registration\models.py:4: DeprecationWarning: the sha module is deprec
ated; use the hashlib module instead
import sha
Could be a problem in the future? Can I avoid it without changing django-registration original code?
EDIT
This deprecation warning comes up in Python 2.6.2
No, if it works, leave it. You can consider this something to think about when you upgrade to a new version of Python which actually removes this module.
Deprecated means that you are encouraged not to use it in new code, it doesn't mean you need to modify (and hence break) existing code which uses it.
you should create new issue/ticket/bug on project's site, or report this to developers of the project.
if there is no activity in project, you are free to fix the code locally.
i had the same problem and kept getting mail about a cron job which was throwing deprecation warning so i ran my python script with
-W ignore::DeprecationWarning
since the script is running in a virtualenv which won't be moving to py3k i can live with this
This deprecation warning comes up in Python 2.6 and django-registration v0.7, it dissapears upgrading django-registration to v0.8

No module named backends.default.urls

So I've installed django-registration through easy_install. I'm following a quick start guide and I'm trying to setup my urlConf, however it says module named backends.defauls.urls is not found. What might be the problem ?
import registration
(r'^accounts/', include('registration.backends.default.urls')),
(not my solution, but since it was hidden in a comment)
You need to use use include('registration.urls'),
instead of include('registration.backends.default.urls')
Is the registration module in your PYTHONPATH?
I'd suggest always getting django-registration from Bitbucket: https://bitbucket.org/ubernostrum/django-registration/overview.
I had a similar problem where I installed django-registration using pip install and it wasn't giving me up-to-date code.
I had the same problem. Apparently the server where I'm trying to upload the urls.py script has an older version, 0.7 I think.
My initial workaround was to put django-registration as an app (from the source) and include it in INSTALLED_APPS, with the registration folder right alongside my other apps.
Then the new problem was that the installed version is being looked up before the 'custom' app, especially on imports. For example, in views.py, we have an
from registration.backends import get_backend
which seems to be missing from the 0.7 version. So this raises an exception, but checking on the registration app the function is there in registration/backend/init.py.
This causes clashes between the custom registration app (0.8) and the one installed server-wide (0.7) that I can't seem to get around to.

Categories