32👍
This error belongs to Django versions. If you want to use Django 4.* you need to find:
from django.utils.translation import ugettext_lazy as _
and change to:
from django.utils.translation import gettext_lazy as _
Happy Coding 🙂
11👍
Was just about to ask the version but the note (django 4.01) helped. ‘ugettext_lazy’ seems to be used by the app you are trying to use as well.
‘ugettext_lazy’ has been deprecated for django 3+ so you won’t be able to use that with a django version >= 3.
https://code.djangoproject.com/ticket/30165
- [Django]-WARNING Not Found: /favicon.ico in Django
- [Django]-Redirect / return to same (previous) page in Django?
- [Django]-How do I construct a Django reverse/url using query args?
7👍
I also got the same issue while using django-hitcount
views.py
from hitcount.views import HitCountDetailView
class PostDetailView(HitCountDetailView):
model = Post
template_name = 'blog/post.html'
slug_field = "slug"
count_hit = True
settings.py
INSTALLED_APPS = [
'hitcount',
.....]
One answer is ugettext_lazy has been removed in Django 4.0 57. Please use gettext_lazy instead
""
from django.utils.translation import gettext_lazy as _
I put this line of code in the views.py, and got the same error.
- [Django]-Gunicorn, no module named 'myproject
- [Django]-How to group by AND aggregate with Django
- [Django]-Django dump data for a single model?
2👍
I strongly recommend to downgrade Django from "4.x.x" to "3.x.x" to solve your errors:
pip install django==3.*
Because Django 4.x.x is very new so some packages don’t catch up with Django 4.x.x. So, if you keep using Django 4.x.x, you will get the same or similar errors in the near future then you will spend a lot of time to solve these errors because of Django 4.x.x.
Actually, I got the same or similar errors when using "django-graphql-jwt", "graphene-django" and so on. Then, for some packages, I could solve such errors but for some packages, I could solve but new other errors occurred then, I couldn’t solve these new other errors.
Finally, I noticed I spent a lot of time to solve such errors because of Django 4.x.x. So again, I strongly recommend to downgrade Django from "4.x.x" to "3.x.x" to solve your errors:
pip install django==3.*
- [Django]-Accelerate bulk insert using Django's ORM?
- [Django]-How to submit form without refreshing page using Django, Ajax, jQuery?
- [Django]-Parsing a Datetime String into a Django DateTimeField
2👍
If you are using django 4.* versions, then you will have to replace "ugettext_lazy" with "gettext_lazy" in import statements where ever applicable.
In my case I was getting error "unable to import ‘ugettext_lazy’" even after this change. I had to upgrade "django-rest-passwordreset" from version 1.1.0 to 1.2.1 to fix the issue.
pip3 install django-rest-passwordreset==1.2.1.
Check for any dependent library similar to above which still uses the deprecated version and then upgrade it.
- [Django]-Get all table names in a Django app
- [Django]-Fields.E304 Reverse accessor clashes in Django
- [Django]-How to change field name in Django REST Framework
0👍
I have solved the problem by installing the django==3.2 instead of the latest version of Django.
But I`ll still check for the pypi update for the usage in the latest version of Django.
- [Django]-Django filter on the basis of text length
- [Django]-Error: could not determine PostgreSQL version from '10.3' – Django on Heroku
- [Django]-Django multi-level template extends and nested blocks
- [Django]-How to limit columns returned by Django query?
- [Django]-Django no such table:
- [Django]-Django can't find new sqlite version? (SQLite 3.8.3 or later is required (found 3.7.17))
-1👍
You must install the django-admin-honeypot library like this:
pip install django-admin-honeypot-updated-2021
with that the problem is solved
- [Django]-How to pass a message from HttpResponseRedirect in Django?
- [Django]-Django URL Redirect
- [Django]-Easiest way to rename a model using Django/South?