Heroku set default site - django

I have created a new Heroku site and I am developing it on my Linux box, using Django. The standard "getting started" site Heroku created for me is called "gettingstarted". How can I change that / configure Heroku to forget about it?
I was reading through the Django tutorial, which explains how to create a new site (django-admin startproject my_site). I did this successfully for a demo project. Then I tried to do it under the Heroku directory, because I wanted a better name for my site than "gettingstarted". I noticed that every time I start the Heroku server under my project, it says ...using settings 'gettingstarted.settings'. I found that this is configured in manage.py and I change it.
This is the directory layout I have
/some/path/heroku_random_name/gettingstarted/settings.py
/some/path/heroku_random_name/my_site/settings.py
/some/path/heroku_random_name/my_app
This is what I have in
/some/path/heroku_random_name/manage.py
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'my_site.settings')
so I would expect that the site that matters is my_site.
I got it to the point where I can run the site successfully on my local machine, and I can tell that it using the settings from my_site. But when I deploy the project to Heroku, it does not recognize my_app until I register it in gettingstarted/settings.py. In other words, when running in Heroku, it is still using gettingstarted as the site to run.
I am new to all this, so I left gettingstarted in the project, because I am afraid to break things. But how can I configure Heroku to execute settings from my_site and not from gettingstarted?

Found it: it's configured in Procfile.
It's confusing because it's configured in one place for running locally and in a different place for running hosted at Heroku.

Related

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

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.

Django: Testing locally before pushing app to Heroku

I've followed the instructions from Heroku's "Getting Started with Django", and successfully deployed my application on the Heroku server.
However, there wasn't any tutorial on how to test my application locally before committing and pushing any change on my codes. For example, after I make some minor changes on my css file or Django views, I want to test it on my local computer first, instead of having to do "git push heroku master" every time..
How do I do this with Heroku?
Thanks
To test your app locally you don't need to use Heroku. Simply go to the folder where your manage.py is and do:
python manage.py runserver
It will fire up a development web server with your app you can access using the following URL in your browser: http://localhost:8000.
This web server reloads automatically when you make changes to the Python code. See the Django tutorial: https://docs.djangoproject.com/en/1.7/intro/tutorial01/#the-development-server
Additionally, you might need to set some variables in your environment (export VARNAME=value) to make it work with 12-factor-style settings.

Heroku app with Django and postgres crashing unexpectdly

I am new to Django development, but I am in a situation where I need to deploy a large project on Heroku.
I ran my app in local system, it worked fine.
I pushed the same to Heroku and it also worked fine. But after few hours I open my app URL in browser , then app is saying Some thing has broken,intimated to admin.
The app worked fine before few hours, but what happened after few hours.
I just pushed my old DB backup to Heroku DB, Thats it app running fine now.
But I confused what happened to my app, I am facing this problem again and again,
how can I avoid this problem in future.
My app configuration:
psycopg2==2.4.5
Django==1.4
This could be a number of causes. It sounds more like a database issue. I would run the following command
heroku pg # TAKE NOTE OF THE HEROKU_POSTGRESQL_[COLOR]_URL
heroku pg:reset HEROKU_POSTGRESQL_[COLOR]_URL --confirm [appname]
This will reset your postgres database that is the active one, remove all tables etc.
Then I would run the regular command to get your database backup and running.
manage.py syncdb
You can also do the following
manage.py validate
This will go through your modules and tell you if any errors are present.
If that fails - enable debug in your settings.py file.
Also you can run "heroku logs" this will tell you the last few errors and statuses that have been hit with your app.
Let me know if this works, if not I will help debug further.

Deploying a "working when run locally via pycharm" django app to webfaction

I've been following the steps in the box under "Configuring Django" here to try and get the django app up onto webfaction after getting it to work locally.
I zipped my project folder and used scp myproject.zip catubc#web513.webfaction.com to get it up. I then used ssh and moved the zip to $HOME/webapps/plot_composite_metrics as the linked steps instruct and unzipped it there. Since the name of my project is "myproject" I didn't have to do steps 6-7.
From the webfaction control panel I have made an application and called it plot_composite_metrics, Django 1.9.1 (mod_wsgi 4.4.21/Python 2.7). I also made a new website called good_morning_cat and added plot_composite_metrics to it.
I have ALLOWED_HOSTS = ['catubc.webfactional.com'] in settings.py
So, as per this example why do I get a "server not found" when I navigate to http://good_morning_cat.catubc.webfactional.com/? What did I forget to do to link my working-locally via pycharm app to said domain?
I have seen this related question, sadly I believe I am using the correct python version, so that's not the issue. Additionally, I do have a paid account if that makes any difference.
You have to add all the domains in the WebFaction control panel, i e http://good_morning_cat.catubc.webfactional.com/ as well.
http://catubc.webfactional.com/ works as this is what you have specified, it's resolved anyway. There's an ImportError because you haven't installed all your dependencies.