here is a question i can use django time zone for utc and it worked fine
but when i switch the default time zone to 'Asia/Tehran' it wont work and i get the error
ValueError: Incorrect timezone setting: ASIA/TEHRAN
the actual code in settings.py is:
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Tehran'
USE_I18N = True
USE_L10N = True
USE_TZ = True
and it is on django time zone list i checked it
the system is ubuntu 20 and django version is 3.2
try this
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC+3:30'
USE_I18N = True
USE_L10N = True
USE_TZ = True
Related
I'm trying to add multi language support for a django project using Django i18n official documentaion:
https://docs.djangoproject.com/en/4.1/topics/i18n/translation/
When I change the LANGUAGE_CODE to something like 'fa', by default the admin panel changes to RTL.
But the problem is when I use other RTL languages like 'ku' (kurdish) the page remains in ltr.
I know we can change the css manualy, but wonder what is the problem here and how some languages like Arabic or persian does the RTL part automaticaly but others dont.
Thanks in advance
# settings.py
LANGUAGE_CODE = 'en-us'
USE_I18N = True
USE_L10N = True
TIME_ZONE = 'UTC'
USE_TZ = True
LANGUAGES = (
('en', _('English')),
('ku', _('Kurdish')),
('fa', _('Persian')),
)
LOCALE_PATHS = [
Path(BASE_DIR, 'django_i18n', 'locale'),
]
# url.py
urlpatterns = i18n_patterns(
path('admin/', admin.site.urls),
) +static(settings.MEDIA_URL, document_root= settings.MEDIA_ROOT)
just found the answer here:
https://github.com/django/django/blob/main/django/conf/global_settings.py#L158
So all I had to do was add this to setting.py:
LANGUAGES_BIDI = ["ku",]
There are two working versions of the translation on the site - Russian and English using i18n. How to make sure that everyone has a website loaded in Russian and then, at the request of the user, he can change it to English?
MIDDLEWARE = [
...
'django.middleware.locale.LocaleMiddleware',
...
]
LANGUAGE_CODE = 'ru'
LANGUAGES = (
('ru', _('Russian')),
('en', _('English')),
)
LOCALE_PATHS = (
os.path.join(BASE_DIR, 'locale'),
)
TIME_ZONE = 'Europe/Kiev'
USE_I18N = True
USE_L10N = True
USE_TZ = True
I've already translated my project in Malagasy (mg_Mg) but when installing django-allauth and override templates, translation won't be applied.
After python manage.py makemessages, python manage.py compilemessages and testing some translations eg: sign up -> Hisoratra anarana in render it show sign up.
But in my local app, all templates are translated correctly.
In config/setting.py
import environ
BASE_DIR = environ.Path(__file__) - 2
...
# Internationalization
# https://docs.djangoproject.com/en/2.2/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
LANGUAGES = [
('en-us', 'English'),
('fr-fr', 'French'),
('mg-mg', 'Malagasy'),
]
LOCALE_PATHS = [BASE_DIR('locale')]
In fandaharana/views.py
def month(request, month_num, year_num):
translation.activate('mg-mg')
...
return render(request, 'month.html', data)
Trying my hands on Django. TIME_ZONEat admin module shows different than the local time. I would like to edit the time according to the current time. Which Django file should I edit to synchronize the time?
I tried the documentation on official Django website but did not help me out.
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
```
On your settings.py, add a TIME_ZONE config:
E.G:
TIME_ZONE = "UTC"
or
TIME_ZONE = "America/Boise"
Plus, enable USE_TZ:
USE_TZ = True
You can read more here
i am using django-allauth and since a big update in my dependencies for some reason all the emails are being sent in English and one it is mixed, a sentence it is in Spanish and the rest in English, even when LANGUAGE_CODE it is defined with my lang (es-ES, i tried only "es" too) at my project settings file.
The settings (base.py):
########## GENERAL CONFIGURATION
TIME_ZONE = 'America/Argentina/Cordoba'
LANGUAGE_CODE = 'es-ES'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
USE_TZ = True
########## END GENERAL CONFIGURATION
########## SOCIALACCOUNT CONFIGURATION
SOCIALACCOUNT_EMAIL_VERIFICATION = 'optional'
SOCIALACCOUNT_QUERY_EMAIL = True
SOCIALACCOUNT_AUTO_SIGNUP = True
SOCIALACCOUNT_EMAIL_REQUIRED = True
SOCIALACCOUNT_PROVIDERS = \
{'facebook':
{'SCOPE': ['email',],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'METHOD': 'js_sdk',
'LOCALE_FUNC': lambda request: 'es-ES',
'VERIFIED_EMAIL': True}}
ACCOUNT_AUTHENTICATION_METHOD = "username_email"
ACCOUNT_EMAIL_REQUIRED = True
ACCOUNT_EMAIL_VERIFICATION = "optional"
ACCOUNT_UNIQUE_EMAIL = True
ACCOUNT_USERNAME_REQUIRED = True
ACCOUNT_USERNAME_MIN_LENGTH = 5
ACCOUNT_PASSWORD_MIN_LENGTH = 6
ACCOUNT_LOGIN_ON_EMAIL_CONFIRMATION = True
ACCOUNT_SIGNUP_FORM_CLASS = 'algo.forms.SignupForm'
########## END SOCIALACCOUNT CONFIGURATION
I am using django 1.10.2 and allauth 0.27.0, i have uninstalled allauth and re-installed but the problem it is still there.
What can be the issue? Thanks a lot!