i have a django project that it should have ability to change the database's port dynamically for security reasons.
for example there should be a template like ( port= ) and the administrator should enter a port and change the default one. how to do this?
thanks.
If you are using SQLite database which comes embedded in Django by default so in order to change the database port you have to change the run server port of Django also.
You can add these mentioned below lines in your manage.py file
from django.core.management.commands.run server import Command as run server
runserver.default_port="8001"
Related
To be more specific, I want to retrieve db setting from a config server when django project starts, and use it to setup django db connection
Someday in the future, the setting in the config server may be changed (for example, change the user password) and pushed to django project then reset the db connection, so I can use new setting without restarting django project or updating project code
Is there a way to do that?
Or what's the right way to hide the db sensitive information (password, etc) from django project code?
Any helps will be grateful, thanks~
i followed this solution to run customer django command programmatically , but it is limited for just one database connection.
I have django app configured with multiple database , is it possible to run custom django command using specific database connection?
exactly like when we use connections["DB_NAME_CONNECTION"].cursor() to execute an sql query
thanks a lot for your help!
One option is to create a new settings module (here's a guide) that contains your specific database connection configuration, and then use that settings module when using call_command():
management.call_command('mycommand', '--settings=mysite.settings.specificconnection')
Good morning. I have a dedicated ubuntu server behind my company's firewall. It is using Django, Gunicorn, and Nginx to serve an Intranet application to employees. The original app responds to the URL [server_name]/[original_application_name]. I want to serve additional apps from this server. I have followed this tutorial as I did when setting up the original app.
I can run Gunicorn and serve the app, I have created a second systemd service file that appears steady (copied from the original app with paths changed - service runs), same for a new 'sites-available' file in Nginx (copied from original and modified), new .sock file exists, binding appears successful. However, I have yet to hit on the right configuration combination between settings.py [allowed_hosts], [new_app].service, and nginx etc.
The original app is running and when I try a URL related to the new app it gives an error saying it cannot find the request in the url.py of the original app. The new app would be used by the IT dept. Ideally, the new URL would be something like: it.[server_name]/[new_application_name].
I have looked through other cases with this problem but most use Apache or are on a public hosting site. I have seen this but it requires a "socket file". My original app is not using a socket file. I was hoping to do this without interfering with the original app. Is a "socket file" required? How can I configure this to serve both apps? Never having done this, what will the new URL be? The URL for the admin site in both apps is 'admin/', how can I accommodate this? Thanks!
I combined into one file as you suggested and I am almost there! I have original site responding at [server_name]/inventory and new site responding at [server_name]/assets. Great! My only problem is the admin page. In both apps the admin site is called admin! So, [server_name]/admin brings up the original site. How can I get to the new admin page?
I have a website that written by django and also same django code on my pc. you call the website www.mywebsite.com and my localhost on my pc is www.127.0.0.1.com, I use the same database model object for two database but I don't want to change my website's database by www.mywebsite.com/admin. I prefer change database on my pc that is www.127.0.0.1.com/admin and update my website by output of that. I should note that I use postgresql with same table and field for both. Please help me. thanks.
I was following this link:
http://www.mindissoftware.com/2014/09/11/Run-Odoo-in-PyCharm-Ubuntu/
I changed the openerp-server.conf file and run the Database located at another machine using host address.
When I run the odoo in Pycharm it throws the error as
Running as user 'root' is a security risk, aborting.
Please help me
You must be trying to run Odoo with the root account: either you logged in as rootor you are running PyCharm/Odoo with sudo.
SnippetBucket Expert for Odoo
Running as user 'root' is a security risk, aborting.
Odoo rules:
1. Odoo can't run with root user, Its because of good govern of ERP Security
2. Odoo - Postgresql, You should not use "postgres" user to run odoo, instead create superuser of postgresql and connect it.
For pycharm, make sure you not run pycharm with root or pycharm don't operate terminal under root. Desktop specific stuff.
Its better to create desktop user, with same name create postgresql super user.
than with newly created desktop user use pycharm. make better to work with odoo.
G-Edit editor and plugins are my favoite editor, keep less memory and works faster. G-Edit Odoo Snippets gives faster to work.
Thanks
SnippetBucket.com