Django Cookiecutter Production Server Setup on DigitalOcean - django

I am trying to setup my Django Cookiecutter code on an Ubuntu server hosted on Digital Ocean. (My first attempt at such a thing.)
It does not appear that my .env file is loading?
DATABASE_URL=postgres://myapp:pwd123#127.0.0.1:5432/myapp
DJANGO_ALLOWED_HOSTS=187.99.73.187,myapp.com,187.99.73.187:8000
DJANGO_ADMIN_URL=admin
DJANGO_SETTINGS_MODULE=config.settings.production
DJANGO_SECRET_KEY=A8fpfkN5}...m5~^jggSo3wq`0Z*
I am using the latest version of Cookiecutter. https://github.com/pydanny/cookiecutter-django
Do I have to do something special to activate/recognize this code?
Right now I am getting an error of add '187.99.73.187' to ALLOWED_HOSTS. But it is in the env file.
I also had Postgres error based on not getting data from this new .env file.
I see instructions and videos for setting up Cookiecutter on Docker, Heroku and PythonAnywhere. Just not for a simple Linux installation.
Thanks.

Related

/opt/alt/python39/bin/lswsgi: No such file or directory

I have a shared Cpanel host with the Litespeed web server. I want to deploy a Django application on it. After creating a Python application inside the Cpanel where I have not deployed the application on the host I try loading the website, and instead of displaying the Django version, I face 503 Unavailable!!
Also inside the "stderr.log" file, there is the following error.
/usr/local/lsws/fcgi-bin/lswsgi_wrapper: line 9: /opt/alt/python39/bin/lswsgi: No such file or directory
I'm creating the application with Python 3.9.
But it works when I create it with Python 3.8 and show the following message when I load the web,
It works!
Python 3.8.6
The issue is mostly caused by the lack of the Python 3.9 WSGI package. On out-of-date versions of LiteSpeed, the package needs to be installed manually.
To work around this, first ensure that LiteSpeed is up to date. LiteSpeed must be at version 5.4.10 for this to work. Once that is confirmed, execute the following script from LiteSpeed. It will pull the required Python Selector packages:
/usr/local/lsws/admin/misc/enable_ruby_python_selector.sh
Refer cpanel support

How to set virtualenv to stay active on a host server

I created a website that uses vuejs as the frontend and django as the backend with another service running behind everything that im making api calls to.
So django is setup in a way to look at the dist folder of Vuejs and serve it if you run manage.py runserver. but the problem is that my service that I created is
is also in python and it needs to run in a virtualenv in order to work (It uses tensorflow 1.15.2 and this can only run in a contained environment)
I'm sitting here and wondering how I can deploy the django application and keep the virtualenv active and Im coming up with nothing, I've tried doing some research on this but everything I found was not relevant to my problem. I've deployed it and when I close the ssh connection the virtualenv stops.
If there is anyone that can enlighten my ways I would appreciate it.
i think you need to nginx: https://www.digitalocean.com/community/tutorials/how-to-set-up-django-with-postgres-nginx-and-gunicorn-on-ubuntu-16-04
if you are search for keep states just in terminal i suggest tmux https://github.com/tmux/tmux/wiki
You can use uWSGI and nginx to deploy Django apps on server. Here's helpful articles:
https://www.digitalocean.com/community/tutorials/how-to-set-up-uwsgi-and-nginx-to-serve-python-apps-on-centos-7
https://www.digitalocean.com/community/tutorials/how-to-set-up-uwsgi-and-nginx-to-serve-python-apps-on-centos-7
Django official docs also has a page about it: https://docs.djangoproject.com/en/3.1/howto/deployment/wsgi/uwsgi/
There are articles from developers so you can refer them in case you get stuck anywhere:
https://www.freecodecamp.org/news/django-uwsgi-nginx-postgresql-setup-on-aws-ec2-ubuntu16-04-with-python-3-6-6c58698ae9d3/
https://medium.com/#biswashirok/deploying-django-python-3-6-to-digital-ocean-with-uwsgi-nginx-ubuntu-18-04-3f8c2731ade1

What are the localhost URLs for OpenShift hosted Django apps

I created a Django application locally and then using the django openshift template from
here I uploaded it to OpenShift successfully. Now I'm trying to work on the local repository for adding additional features but when I run the server locally, I get a bad url error.
What I would like to know is how do I locally host a OpenShift Django App?
I also tried rhc tail -a appname but that only gets me a small amount of debug info If I can't locally host it then is there a way with which I can see the python print() output for the app hosted on OpenShift?

Deploying Django App on Heroku using Windows

I want to deploy my django app on heroku , which I have built on Windows machine.
Can I deploy the same application using heroku toolbelt for windows.
Or I have to setup all the things on a unix machine.
And one more thing the application uses Python 3 and Django 1.8
Will that be any problem.
There aren't any special process listed in the docs for windows usersYou should actually deploy from a unix environment, you have to create your Procfile, requirements.txt and make some changes to your settings.py file, it's easy and straight forward.
A step by step guide can be found here https://devcenter.heroku.com/articles/getting-started-with-django
Some problems you may encouter:
Internal Server Error heroku/django
Django migrations fail in heroku
Also make sure you add your migrations and cache folders to your .gitignore file.

How to debug Two Scoops of Django project skeleton on production server running gunicorn

I don't get a traceback from the Two Scoops project (https://github.com/twoscoops/django-twoscoops-project).
I'm running a Ubuntu 12.04 production server on Virtualbox and I setup gunicorn. I'm trying to learn how to setup a production server so I can host it on Digital Ocean. So far, I've been able to get gunicorn to run by typing this in /myproject/myproject/ (the same directory as my manage.py):
gunicorn wsgi # run this in the same directory as wsgi.py
Then I type:
curl localhost:8000
But I only get back:
<\h1\> Whoops! <\h1>
I did the following:
export DJANGO_SETTINGS_MODULE=myproject.settings.production
But I still get the same "whoops" page. Any thoughts on how I can get the Python traceback or Django debug page to work?
I figured out how to turn on the debugging in a production setup.
You have to goto /settings/base.py and set DEBUG = True. It was False by default.