Share this link with others:
https://digitalnotebooks.co/accounts/shared/e4b59841-7fde-4c71-aff4-39aadefa7dd9/1. Go to PythonAnywhere.com Create an account. We will use the FREE BEGINNER'S ACCOUNT.
2. Make sure you comply the DEPLOYMENT CHECKLIST
a. Create and update REQUIREMENTS.TXT
$ pip freeze > requirements.txt
b. install the package, backports.zoneinfo, only works if the server's python version is less than 3.9. See the documentation here. To check your laptop's python version, run $ python --version
$ pip install backports.zoneinfo
and add this condition in REQUREMENTS.TXT. This means that if Python server is less than 3.9, then it will install backports.zoneinfo, otherwise, it wont install.
backports.zoneinfo;python_version<"3.9"
c. remove the db.sqlite3 from .gitignore
d. remove media from .gitignore
.ENV file should NOT BE COMMITTED INTO GITHUB BUT YOU WILL NEED TO CREATE THIS ONCE YOU ARE IN THE DEPLOYMENT SERVER. You can FOLLOW THIS GUIDE how to handle secret information in PythonANywhere.
4. Push the changes to GITHUB
$ git status
$ git add -A
$ git commit -m "deployment"
$ git push origin main
*YOU CREATED README.MD IN GITHUB BUT NOT IN YOUR LOCAL REPOSITORY (your laptop's project folder), so you will get an error when you neet to push the changes into github. To update your local repository, issue the command:
$ git pull origin main
5. Follow the documentation for deploying Django project in PythonAnywhere.com
https://help.pythonanywhere.com/pages/DeployExistingDjangoProject/
6. On the PythonAnywhere Dashboard, click on BASH (this is in one of the consoles)
To get your Github Repository link (make sure this repository is public), go to Github and click COPY.
Public link: https://github.com/RosyCodes/Django-blog.git
7. When you click on BASH, you can check the current folder you are in by using PWD
8. Now clone your Github project by using GIT CLONE <PROJECT LINK>
9. Type LS (ls) and it will list your Github project.
10. Create a virtual environment. Follow the documentation.
$ mkvirtualenv --python=/usr/bin/python3.10 mysite-virtualenv
WE HAVE REQUIREMENTS.TXT, SO WE JUST NEED TO INSTALL OUR REQUIREMENTS.TXT (mysite-virtualenv)$ pip install -r requirements.txt
If we run the code right away, it will give us an error because when use LS (listing current files/folders, you will only see your project name), so you need to change directory and install the file, REQUIREMENT.TXT.
Wait until all packages are installed. This may take time.
11. Set up the Web app and WSGI. Go to the BASH MENU (HAMBURGER DASH)
On the Bash Menu tab, select WEB, and right click to OPEN TO NEW TAB.
Opened WEB on a new tab as you need the bash terminal to run some codes.
12. Click on ADD A NEW WEB APP
13. Select Python 3.10 because when you make your virtual environment in step 10, the Python version used was 3.10.
14. This will show up and will create the WSGI files for you.
15. This appears.
16. In the CODE section, enter the path. To do this, go back to your bash terminal and issue the commands, PWD and LS, to see the current path and files/folders. You need to copy the highlighted path and enter this in your web app path.
Click the CHECK MARK:
.
No PDF file attached.