How can I detect third party package translations - django

I’ve made a Django third party app, which I’m using in a Django project, running in Docker Compose. I want to translate ValidationError messages from the app inside the project, but the makemessages command doesn’t detect them. I thought, I’ll just add them manually, but when I call makemessages after that, my manually added translations are commented out.
I’ve looked for solutions, and found those SO-posts
Django translations of third party apps
Django's I18N with third-party apps
The posts explain that I should be using symlinks, but I have had no success of doing it (same results as above), see an example below:
docker-compose exec web ln -s /usr/local/lib/python3.8/site-packages/mypackage ./
docker-compose exec web python manage.py makemessages --locale=da --symlinks
So I’m looking for help, what am I doing wrong or could I do something else? Maybe translate the messages inside the third party app itself like Django Rest Framework does?
I hope you can help, very much looking forward for anything that can point me in the right direction.

Related

Django and Django rest framework

I was following a resource https://blog.learncodeonline.in/how-to-integrate-razorpay-payment-gateway-with-django-rest-framework-and-reactjs
Instead of using reactjs for the front end. How can i make the frontend using Django templates? Please help. Thank you.
It will be same as any normal Django Project. Instead of exposing APIs you can use normal Django Templating for your response.
Had made a similar project which might help you to understand the concepts.
To run:
pip3 install -r requirements.txt
python3 manage.py runserver
Access the frontend template page on localhost:8000/customer/template/
Access the GET & POST APIs at localhost:8000/customer/
Link to the project: Simple CRM Project
If you need any help with it you can raise an issue at Github. Hope, it helps.

Basic cookiecutter-flask implementation

So I have got my app up and running. However it still runs off the cmd console at the moment. Next steps is for me to build a simple web app interface.
After much research, rather than to setup an entire flask site from scratch. I decided to use cookiecutter-flask from https://github.com/konstantint/cookiecutter-flask boilerplate to quickly get the boilerplate up and running.
Everything looks good in a sense where I understand:
Templating
App function
Static
I still cannot figure out how to get the user registration function working. I keep getting a wsgi error. I know is somewhat related to my database not being installed.
Not specific to that, what I am really looking for is a walk through tutorial on how to get it working by bare minimum and then enhance from there.
I have been looking around for tutorials and walk through but to no avail.
Appreciate any help out there.
After clone you have to do these steps ... These will create the database tables for you...
python manage.py db init
python manage.py db migrate
python manage.py db upgrade
python manage.py server

Django restframework bootstrap static files

I have a regular django site, with djangorestframework (v2.3.14) serving restful api under "/api". On local box everything works fine (mac / mavericks), on remote box (Ubuntu 12) the API browser comes up but all the bootstrap stuff is missing (the page looks like it's out of 1992 prototype instead of pretty bootstrap theme i see locally).
All the pip dependencies have been upgraded and are identical. Locally running site through PyCharm, remotely it is running on WSGI.
What can I check to see what the issue is and resolve it??
I suppose that under PyCharm on your local machine you are running the development server, which serves static files directly from your apps and projects internal locations.
After every deployment into production (your WSGI server) you need to collect all static files to a single place, your STATIC_ROOT. This is a job for the django management command collectstatic, see Django docs here.
The command may look like this:
# Executing collectstatic (organize static files)
python /path/to/your/project/manage.py collectstatic --noinput
For further details you may also read Django cannot find static files. Need a second pair of eyes, I'm going crazy.
If this question doesn't help, you can quicly fix it making a link under your proyect's static folder
ln -s /your_env_folder/lib/pythonX.X/site-packages/rest_framework/static/rest_framework rest_framework

How to use django "site" framework on google app engine

I'm going to answer my question. I ask this so that other people who is still searching on how to create a django "site" will have a clear answer.
The django documentation had show how to use the django site framework. But strangely, after googling for quite a while, I can't find a good instruction on how to install the site framework. We all know to install an app, we put 'django.contrib.sites' on the INSTALLED_APP list. But how to add the site? Using the admin interface will result in error that say that the site framework is installed but no site is configured (Duhh!). So, we have to assign SITE_ID on the setting.py. But what is the id? From some source, we know that the it has installed a default site by the domain example.com. But still what is the id? setting it to 0 or 1 will also result in error.
Just read the link:
http://www.allbuttonspressed.com/projects/djangoappengine
Definitely the best tutorial I have found:
Flying with Django on GAE
With this I had my site on appspot after about half an hour.
The answer is....
First, put 'django.contrib.sites' on the installed app list like usual.
Then run
python manage.py syncdb
(At you project directory that is). Then, run:
python manage.py shell
Then, use the following sequence of code:
>>>import django.contrib.sites.models as mod
>>>mod.Site.objects.all().count()
Make sure it prints out 1. If it doesn't you probably haven't run syncdb properly.
>>>msite=mod.Site.objects.all().get()
>>>msite.pk
It will print your default site id. SITE_ID (in setting.py.)to the number given. That should do it. At least on development server.
ps: Strangely, mine is 383L. Not 0 or 1. This is probably google app engine with django nonrel specific.

How can I deploy a django appserver as an egg, running behind fastcgi?

I want to run a django appserver behind apache/fastcgi. That's no problem, django does that out of the box.
I want this appserver to be deployable via setuptools. That is, I will make it as an egg and install it with easy_install. And that part I can also handle, even though setuptools is not a standard complement to a django appserver.
But what I can't figure out is how the dispatch.fcgi would actually call into this my_app.egg to "start" the server process. Has anyone ever run in this config before?
What you probably want to do instead is use something like Paste to delegate to your egg (see example Paste deployment config file here); this means doing the flup stuff (which translates FastCGI to WSGI) manually since you'll be pointing flup at Paste instead of at Django, but you can look at the Django management script to find out how it works.