Damir
Implementing Localization in DRF. In an ongoing development project of DRF, I have to support the translation for multiple languages. My question is how should I do it. Like upgrading existing APIs with the translated response (need to alter the viwesets and serializers). Having a separate translation APIs. The data which is added from the CMS is how it's translation to be done, cause from the CMS the translation can be updated as well and storing so much of the data for each language in the DB doesn't sound good to me. I know how the translation works with django and the Rosetta as well for the updatable interface. My question is how should I approach it for the entire project. Please guide me, if you can it would be very helpful. Thanks.
We use default django translations module settings.py LANGUAGES = ( ('ru', 'Russian'), ('kk', 'Kazakh'), ('en', 'English'), ) In your project from django.utils.translation import gettext_lazy as _ text = _('Your text that need translate') After create folder locale in prjects root path, add text in your project and use command: ./manage.py makemessages --no-location --all You need to fill created localization files When deploy server or run project use: ./manage.py compilemessages If there are a lot of texts for localization, then you can use autotranslation using the google api and modeltranslation library # Auto translate settings: # A workaround for the error: # import collections # collections.MutableSequence = collections.abc.MutableSequence # GOOGLE_TRANSLATE_KEY = '' # AUTOTRANSLATE_TRANSLATOR_SERVICE = 'autotranslate.services.GoogleAPITranslatorService' # Then call: # pip install django-autotranslate # pip install google-api-python-client # python manage.py translate_messages -s ru -l en # python manage.py translate_messages -s ru -l ru After that, when a request is sent, you need to specify Accept-Language: en in the Header
Minko
Can you please tell me what the issue might be when you try to execute a query using a template?
Minko
This syllabus can be modified as necessary to fit specific educational needs or institutional requirements. request session start redirect start 127.0.0.1 - - [04/Dec/2024 06:18:11] "POST /save_document/ HTTP/1.1" 302 - check 1 Error processing the document: Package not found at '/Users/moldiresbota/Desktop/project_verst — копия/myproject/documents/syllabus_template/syllabus_template.docx' Internal Server Error: /generate_document 127.0.0.1 - - [04/Dec/2024 06:18:11] "GET /generate_document HTTP/1.1" 500 - ^C%
Minko
Try to get rid of Russian filepaths
It’s just name of the folder Everything is in English
Maxim
It’s just name of the folder Everything is in English
"копия" is not an English word
Zulik
Website django unavailable
Doragonsureiyā
Website django unavailable
Impossible to help without details. Read this please: http://www.catb.org/~esr/faqs/smart-questions.html
Zulik
http://www.catb.org/~esr/faqs/smart-questions.html Website unavailable
....
Done bro
Ok bro
Pritirekha
How to create user management module using LDAP function , can someone give me basic ideas about it . I don't know about LDAP.
Leonardo
I need it to continuos my study :(
Charly
I need it to continuos my study :(
You can use the documentation instead of asking for pirated books
mahshid
Hi guys I’m really new in Django And in my first project I kept receiving 400 error bad request So I changed my debug = false but I have no idea what should I write in my allowed hosts At first I wrote [‘*’] but It didn’t work Now I am getting a Server error 500 I don’t know what to do 🥺🥺
mahshid
127.0.0.1 write in allowed hosts
I did , but I keeps giving me the server error 500
Даниил
I did , but I keeps giving me the server error 500
Did you follow the django off tutorial?
Maroua
I did , but I keeps giving me the server error 500
DEBUG = False ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
Maroua
try this
mahshid
Did you follow the django off tutorial?
I don’t know what that is
Даниил
I don’t know what that is
Django official tutorial Gets you through the steps of website development
mahshid
DEBUG = False ALLOWED_HOSTS = ['127.0.0.1', 'localhost']
I tried it now And it still gives me the error 🤦🏻‍♀️
Maroua
I tried it now And it still gives me the error 🤦🏻‍♀️
try again to set the debug = true and clear the browser cache , i had the same problem in my first project and turned out that its all becuz of the cache🥲
mahshid
it worked ?
No 🥺🥺
Maroua
aww what else did u try ?
mahshid
aww what else did u try ?
I think I tried everything I saw on the internet and YouTube ….
Maroua
I think I tried everything I saw on the internet and YouTube ….
it will make ur project more complicated if you have time start again and if you're learning alone try a diffrent tutos everytime untli u find the one the suits u and simlify things to you
Maroua
I’m learning by reading w3schools It seems easy for me to Is it good though?
never tried to rely on them to learn a hole course but as a source of coding informations yes
奈姆
I read it online
I don't think they are related by the way.
mahshid
I don't think they are related by the way.
🤦🏻‍♀️ok I will search for something else
Maxim
🤦🏻‍♀️ok I will search for something else
it's unlikely that a search can help unless you're trying to figure out the specific cause in your case
Maroua
start again and count your steps
Maroua
you should know what are you doing from the start
you7
{% for Char in hello %} <marquee> {{ Char }} </marquee> {% endfor %}
Shaikh Ahmad Raza
How to add products into cart? Note- I have'nt created login form yet.
Otabek
How to add products into cart? Note- I have'nt created login form yet.
There is a book called django 5 by example by Antonio mele in this book the thing you are talking already implemented
Shaikh Ahmad Raza
Exception value - Cannot query "ahmad" must be "Cart" instance.
Allexiusw
Exception value - Cannot query "ahmad" must be "Cart" instance.
It is explicitly saying that your lookup filter is expecting an instance of Cart model and seems to me that you are passing a str... Why don't you share the models and the query that is leading you to this issue?
Mohsen
I have a separate front end and backend site and I am trying to enable users on the front end to reset their password. I have created an endpoint for them to do so which works when accessed via the backend site. But when I try to access the endpoint via Insomnia I get: Forbidden (403) CSRF verification failed. Request aborted. from allauth.account.views import ConfirmEmailView,PasswordResetView path("api/v1/auth/password/reset/", PasswordResetView.as_view(), name="request_password_reset"),
奈姆
Do you know what CSRF is for?
Mohsen
Do you know what CSRF is for?
So, are you saying that if the user is not logged in, there's no need for this check?
奈姆
no. you have to understand what is the purpose of CSRF first.
奈姆
What is CSRF token? How is it generated? Why most of the API endpoints don't usually rely on CSRF protection?
Mohsen
no. you have to understand what is the purpose of CSRF first.
The purpose of CSRF (Cross-Site Request Forgery) is to prevent malicious requests from being sent to the server on behalf of authenticated users by attackers. In this attack, the attacker sends requests to a legitimate website from another website or via a malicious link, making the request appear as if it's coming from the victim user. To prevent these attacks, CSRF tokens are used. Each request from the user must include a unique token. These tokens help the server verify that the request is genuinely coming from the authenticated user, preventing unauthorized requests from being sent.
奈姆
So, are you saying that if the user is not logged in, there's no need for this check?
Short answer: If you store sensitive data in cookie and your API relies on it to perform auth operations, then you need CSRF protection. Long answer: https://security.stackexchange.com/a/166798
𝑰𝑳𝑰𝒀𝑨
OperationalError at /admin/Blog/post_comment/ no such table: Blog_post_comment What should I do about this error? I even deleted the database and recreated it, but it still didn't work.
𝑰𝑳𝑰𝒀𝑨
HELPPPPP ME
𝑰𝑳𝑰𝒀𝑨
make migrations
i do it but it's not work!
𝑰𝑳𝑰𝒀𝑨
𝑰𝑳𝑰𝒀𝑨
what should i do bro??
Qwerty
yes
manage.py migrate <app_name>
𝑰𝑳𝑰𝒀𝑨
wait
𝑰𝑳𝑰𝒀𝑨
py .\manage.py migrate Blog CommandError: App 'Blog' does not have migrations.
Qwerty
you don't have a table in the database. you must create it there with the commands above
𝑰𝑳𝑰𝒀𝑨
how?
𝑰𝑳𝑰𝒀𝑨
py ./manage.py makemigrations?
𝑰𝑳𝑰𝒀𝑨
Carlos Alberto
https://github.com/advisories/GHSA-m9g8-fxxm-xg86
SKG
raise TemplateSyntaxError( django.template.exceptions.TemplateSyntaxError: 'blog_tags' is not a registered tag library. Must be one of: admin_list admin_modify admin_urls cache i18n l10n log static tz [07/Dec/2024 02:43:16] "GET /blog/2024/12/3/i-think-i-need-some-coffee-and-breadstick/ HTTP/1.1" 500 186957 any one help? i have done everything , created the templatetags directory in the my application which is blog directory , i have __init__.py and blog_tags.py and i call the template tag on top of my base.html file, restarted my server yet its not working
SKG
please help your brother