I have a working Django application in my local machine. I tried hosting this application in Openshift, after following the Openshift official tutorial didn't get any results. Is there any proper resource to deploy local Django applications to openshift
On Openshift you can deploy Django applications using either the Django cartridge or the Python cartridge. Using the Python cartridge is often preferred as it enables you to easily install the latest version of Django using pip.
Are you using the Django or Python cartridge?
To use the Python cartridge you can follow this tutorial:
https://developers.openshift.com/en/python-getting-started.html
You mention that you already have a django application on your local machine. It can be a bit tricky to push an existing project to openshift.
If you create the application using the Python cartridge it will create a git repository for you that you then clone onto your computer. Using the website find the URI for your application repository. You should clone this onto your computer into a separate directory from your existing django project. Look into this new repository and copy the files from that repository into your existing repository. Then you can look at the remote location used in this new repository and set it as a remote in your existing django repository. Then from your existing repository push to the openshift remote using the --force flag.
$ cd /home/user
$ git clone ssh://<user_id_string>#python-yourdomain.rhcloud.com/~/git/python.git/
$ cd python
$ tree . # look at the files in the repository (wsgi.py, etc.)
$ <copy the needed files to your django dir>
$ cd ../<existing_django_dir>
$ git remote add openshift ssh://<user_id_string>#python-yourdomain.rhcloud.com/~/git/python.git/
$ git push -f openshift master
Directions on force push: Force "git push" to overwrite remote files
Related
I have deployed my django-app on heroku with Github.
It is test server so I am using sqlitedb.
But because of the dyno manager, my sqlitedb resets everyday.
So I am going to download only db on heroku.
I tried this command.
heroku git:clone -a APP-NAME
But this clones empty repository.
And when I run $heroku run bash -a APP-NAME command, I got ETIMEOUT error.
Is there any other way to download the source code on heroku?
What you want to do with git is not possible because changes to the database is not versioned.
The command to run bash on Heroku is heroku run bash, not heroku bash run. You may have to specify the app using the -a flag: https://devcenter.heroku.com/articles/heroku-cli-commands#heroku-run
I have solved with downloading the application slug.
If you have not used git to deploy your application, or using heroku git:clone has only created an empty repository, you can download the slug that was build when you application was last deployed.
First, install the heroku-slugs CLI plugin with heroku plugins:install heroku-slugs,
then run:
heroku slugs:download -a APP_NAME
This will download and compress your slug into a directory with the same name as your application.
I am trying to configure web server for Django 2.2.8 on VPS Server as well as Shared Hosting but both are not working. I have configure python on the web server and its shell is working and giving output . But when I am trying to configure Django but its not working Its Giving the blank screen.
I have followed these steps for Django Configuration and followed this link
https://github.com/sparagus/django-shared-hosting-1and1
Access your server via SSH, which will most likely take you to your base directory (your htdocs directory where the directories to your websites are).
Make a directory where you want your Python files to reside and cd into it.
mkdir python_files
cd python_files
Run the build-python.sh
./build-python.sh
install/python3.6.3/bin/python3 -m venv venv
source venv/bin/activate
pip install --upgrade pip
pip install -r requirements.txt
If you get an SSL error here then there's a problem with OpenSSL.
Check if Django is installed correctly.
python -m django --version
Go back to your base directory and start a Django project.
cd ..
django-admin startproject your_site
and so on followed all the steps which are mentioned on the git link but it is showing blank when accessing the url
I successfully installed and setup Django (2.0.2) using Python 3.6.4 on IIS on a remote Windows Server 2012 R2 (in a VPN environment) accordingly to this instruction:
http://blog.mattwoodward.com/2016/07/running-django-application-on-windows.html
I'm using SQL Server as backend and I stored the sensitive data such as the DJANGO_SECRET_KEY, DATABASE_PASSWORD etc. as environment variables in the FastCGI Settings at the IIS (see the above link, section Configure FastCGI in IIS step 14)
At this point I asked me, how to deploy my apps and do all the necessary setps like install packages from requirements.txt, collectstatic, makemigrations etc.
With googleing I found a possible solution using git hooks, especially a post-receive hook accordingly to this post:
https://dylanwooters.wordpress.com/2015/02/21/one-command-deployments-to-iis-using-git/
So I successfully setup Bonobo Git Server on the same IIS accordingly to this instruction:
https://bonobogitserver.com/install/
My thought was to put all the required commands into this post-receive hook file as I would do in the development environment. I ended up with this file at location \inetpub\wwwroot\Bonobo.Git.Server\App_Data\Repositories\myapp-master\hooks\post-receive:
#!/bin/sh
DEPLOYDIR=/c/apps/myapp
VIRTENVDIR=/c/virtualenvs/myapp
GIT_WORK_TREE="$DEPLOYDIR" git checkout -f
cd $VIRTENVDIR
source Scripts/activate
cd $DEPLOYDIR
pip install -r requirements.txt
python manage.py collectstatic --noinput
python manage.py makemigrations
python manage.py migrate
I grant permission to the Scripts/activate file and I receive no erros during push from my development environment. But the current problem is that the command at line 6 doesn't activate the virtual environment and therefore no migrations etc. happens. Normally I would activate the virtual environment with the command line prompt using these commands:
cd C:\virtualenvs\myapp
Scripts\activate.bat
but I can't use this in the post-reveive file because it uses unix-based commands.
Can anyone help me or have a better idea how to deploy in a nicer way in a windows environment without going into the cloud?
I created a personal portfolio website for myself using django and it also includes a blog. You can see the exact directory listing and source code in my github repository by clicking here
I have the procfile and the requirements.txt file as said in the heroku website and did the following in command prompt as directed by heroku :
$ heroku login
$ heroku git:clone -a appname
$ cd appname
$ git add .
$ git commit -am "make it better"
Then collectstatic --noinput error occurred so I did this:
heroku config:set DISABLE_COLLECTSTATIC=1
Then I again repeated the deployment process and this time the deployment was successfull. And then I opened the app but the website did not appear. Instead this appeared.
Please help me deploy this website.
You are probably developing on Windows. Heroku, like most deployment environments, uses Linux; in that environment the file system is case-sensitive. Your Templates directory should be called "templates".
Please note also you should not be committing a lot of this stuff to either Github or Heroku. In particular the venv directory at the base level, and the pycache directories inside each directory, should be excluded. You can use the git exclude functionality to ensure they are not added.
Also it is very strange that you have named your templates with ".php" extensions. There is no PHP involved here.
I have an django project (RESTful API written using Django Rest Framework) which uses the Postgres database.
I have a local git repository of the project and also I have it on my github account, and I want to deploy the porject to heroku.
In the official heroku tutorials, they don't show anything about how to prepare your app to deployment - (requirements file, settings file, Proc File, maybe more stuff that I don't know - which I saw in different tutorials that you need to do).
At the moment I only have the django app without any added file.
My question is - what do I need to do to prepare my app to deployment to heroku? as I said at the moment I have a local git repository and its also on Github.
Thanks!
1) Create a file called Procfile (no extension) in your project root with the following inside:
web: gunicorn APP_NAME.wsgi (replace APP_NAME with your app's name).
2) Pip install gunicorn and dj-database-url
3) In your virtual env terminal, run pip freeze > requirements.txt in your project root (do this every time you pip install any new packages).
4) In your production settings file, add the following to make your database work on heroku:
import dj_database_url
DATABASES['default'] = dj_database_url.config()
Note: This will cause errors in your local environment, so make sure you have a prod.py settings file as well (ask if you need an explanation).
5) Add heroku to your git settings via git remote add heroku git#heroku.com:HEROKU_APP_NAME.git (replace HEROKU_APP_NAME with your Heroku app name).
6) Once you do git add --all, git commit -m "SOME MESSAGE HERE" and git push, you can do git push heroku master.