How change config file for custom folder in opencart Like Admin and catalog - opencart

I Added a new Seller folder with(Model, Controllers, Language, View) in Opencart 3 like Admin and Catalog But when I changed the config file of the seller folder its working fine in localhost but when run in server the server it says "response xyz.com is currently unable to handle this request".
How i can change the config file so it can be accessible in the live server

Related

How to get data from config file (config.json) in real time in settings.py file in django

I have a project made in Django. I have only added social auth for login purposes. I want selected emails only to log in to the website. I used social-auth-app-django library for social auth and added a variable SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_EMAILS to the settings.py file where it contains a list of all the emails permitted for logging in.
My project directory looks something like this:
project_parent/
----project/
--------settings.py
--------wsgi.py
--------asgi.py
--------urls.py
----app/
--------models.py
--------views.py
--------urls.py
--------admin.py
----db.sqlite3
----manage.py
----config.json
Here is the config file:
{
"OAUTH2": {
"WHITELISTED_EMAILS": [
"xyz#gmail.com",
"abc#gmail.com",
"efg#gmail.com",
"lmn#gmail.com"
]
}
}
In settings.py file I have loaded the config file like this:
config = open('./config.json',)
data = json.load(config)
SOCIAL_AUTH_GOOGLE_OAUTH2_WHITELISTED_EMAILS = data['OAUTH2']['WHITELISTED_EMAILS']
I have made a webpage that takes the new mail id (need to add to the config file) and appends that particular mail id (or a list of mail ids) to the config.json file. But now the problem arises, the newly added mails don't reflect directly to the variable defined in the settings.py file. For that, I need to restart the code in order to get the latest config file. Every time I add a mail id, I need to restart the code.
I thought to make a database table in my app folder and load that table in settings.py by import the model from app folder. But on importing, the terminal raises the error as it says app is still not loaded so that I can't use the models inside my app.
Is there a way in which I can directly load the database table without importing the models.py file from app folder? Or if possible to load the config.json file in real-time so that I don't have to restart the code
settings.py in Django is loaded once at execution time, we should not change the values during runtime. Although that is suggested by the docs there are ways you can change the settings values during runtime. You can use django-constance library, and then make a form to update the setting's value during runtime by editing the database value.

Serve multiple Django applications from one server

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?

django cms filer uploads fail

[Update]
I've managed to upload a small file (but not yet a large image). ../media/filer_public/ sub-directories are being correctly created and file correctly uploaded. Need to investigate nginx configurations.
[OP]
I've logged into a new Django CMS system as superuser but cannot Add filer image or Add filer file to a page as the file upload silently fails; very briefly flashing its upload graphics but not actually uploading anything. I believe all the settings.py are correct as static artifacts are rendered correctly and Nginx has credible similar locations for both media and static directories.
I believe all file and directory permissions and ownerships are correct; i.e. that Nginx has user and / or group ownership of the Django CMS app directories and that permissions are correct.
The Postgres table filer_folder has a row for a new filer folder I created when editing a page but no corresponding directory has been created in the file system. I can add text and new text block plugins that get saved correctly.
Django CMS is running in a Docker container web which I have confirmed has rw (read/write) access to a Docker volume.
I see nothing abnormal in webs logs.
How can I find out what's (not) happening?
Simply adding client_max_body_size 10M; to the nginx configuration for the site solved the issue.
Similar issues were addressed in Stackoverflow and elsewhere:
Server Fault
Setting up Django and your web server with uWSGI and nginx

How do you add a Purchased Domain Name using Django need Steps

I recently purchased a Domain Name from GoDaddy and I used Django Frameworks and have already built the site with HTML5 and CSS4 and bootstrap my problem is were do I add my custome Domain Name in Django I have looked everywhere on the web but no one seems to know
Thanks
It seems you are looking for ALLOWED_HOSTS settings. It can be found in your project's settings.py file. Usage:
ALLOWED_HOSTS = ['.example.com']
More info here: https://docs.djangoproject.com/en/stable/ref/settings/#allowed-hosts
I. For your development environment:
Django includes a framework called "Sites" which enables setting the domain name and website name for your Django project through the admin interface. To enable sites, go to the settings.py script of your project and:
add 'django.contrib.sites' to the INSTALLED_APPS
at the bottom of your settings add SITE_ID = 1
migrate your database (open the terminal, go to the project directory, and run $ python manage.py migrate) to create the corresponding records on your database (there is no need to run $ python manage.py makemigrations)
Now you can browse to http://localhost:8000/admin/sites and edit the domain name and website name from your browser. Notice that the admin site should be previously enabled.
Once you save the changes, other django modules will make use of the new domain name and project name (for example: all email you send through an email backend will produce links using your new domain settings).
For more information, check: https://docs.djangoproject.com/en/4.0/ref/contrib/sites/
II. On the production environment:
You will need to choose your django server platform (for example: Amazon AWS EC2, IBM Cloud, Heroku, GoDaddy, etc)
You may find some guides on how to deploy your django app on these links:
AWS: https://dev.to/rmiyazaki6499/deploying-a-production-ready-django-app-on-aws-1pk3
IBM cloud: https://developer.ibm.com/tutorials/deploy-django-applications-to-ibm-cloud/
Heroku: https://www.dothedev.com/blog/deploy-django-app-free-heroku-complete-guide/
GoDaddy: https://www.dothedev.com/blog/2019/12/03/host-your-django-app-on-godaddy/
III. On your domain provider:
Most of the websites offering domain name for sale will provide you with an interface to manage the DNS (Domain Name Service) records for your domain. These records associate the IP address of your website (you should get it from your web server) to your www.domain.com
Likewise, DNS records will associate the mail servers of your choice to your domain.
For an example on how to manage your DNS records go to: https://www.godaddy.com/help/manage-dns-records-680

Akeeba backup Joomla 2.5.14 & cpanel all files unwriteable

I uploaded a website that is working in the localhost using Akeeba backup. It is done by creating a new public_html at the host using its cpanel. Next i transfer the .jpa & the kickstart.php to this new folder. Finally i browse the kickstart.php and restore the website running on joomla 2.5.14.
Accessing the admin panel of Joomla, it reports all folders as WRITEABLE and site runs good. In cpanel all folders permission is set to 755 & files 644 as expected; i then change configuration.php to 444.
However when i try to edit the configuration.php in the host, i found i can't change the file permission or save any edit. This in fact affects all files. After informing the host, they change the file ownership setting, then in cpanel i CAN edit files BUT now Joomla reports all folders become UNWRITEABLE creating more problems eg cannot install new extension; some how Joomla no longer has edit rights to the folders.
More ... at this state, to make a folder WRITEABLE to Joomla, it must be set file permission to 777. It is unexpected & unacceptable; 775 is sufficient for Joomla to report as writeable ie if the host is doing the right thing for Joomla (as i found in another hosting site).
When i tell the host to change it back to the state after Akeeba restoration, they say that will mean they have to set the folders with ownership = nobody.
I would imagine ownership of folders & all its content can be made to be the cpanel user AND the joomla ie php/apache user. Can someone enlighten me this puzzle so that i can talk more intelligently with the host or point where i went wrong. I am getting no where with them.
PS: Latest Sharing Update
The solution is find a host that has Server API showing as cgi/fastcgi which mean that suPHP of Apache is enabled (sorry cannot post .jpg < 10 reputation)
With cgi, Joomla report all 755 folders as writeable.
Now the new question
If the host use Server API = Apache 2.0, how can i enable suPHP from the website?
As you have worked out, suPHP or FastCGI should usually be enabled for Joomla file permissions and file ownership to work as you would expect.
There is a good article on this at: http://boomshadow.net/tech/php-handlers
In a shared hosting environment you don't usually have access to change which PHP file handler is enabled but your web hosting company may be able to change this for you.
If your web hosting company can't enable suPHP or FastCGI, the only other option might be to find a new web hosting company.