Test project for yalantis golang school
- Project is deployed on heroku.
- Project has tests that cover its main functionality.
- Logging is enabled - all basic log messages, as well as all incoming requests and outgoing responses, are logged to the general.log file.
This chapter will cover required steps to deploy your own member_club locally and on heroku.
To do so, you can use GitHub Desktop, git command line tool or just download .zip archive and unpack it on your PC. If you choose to use git command line tool, then run following command in target directory:
git clone https://github.com/Dagunov/member_club.git new_folder_name
Where new_folder_name is name of the folder that will be created automatically.
As soon as you download source code, you can proceed.
-
Python. This project was created with python-3.9.9, but last available version should be ok.
-
Python Django package. To install it you can run next command in your terminal (provided you have python in your PATH):
pip install Django
-
Modify project to run locally. The only step necessary is to change in file settings.py (which is in folder member_club) this line:
DEBUG = FalseTo this line:
DEBUG = TrueIf you do not wish to run project on heroku later and won't install django-heroku package, you should find and comment out this two lines of code:
import django_herokuand
django_heroku.settings(locals()) -
Run project. Run next command in the project root folder to start your local server:
py manage.py runserverYour site should be accessible at http://127.0.0.1:8000/. If you wish to change port or else, you can run next command to view available flags:
py manage.py runserver --help
- Heroku CLI if you do not have (not local) git repository.
- git command line tool, also if you do not have (not local) git repository.
- If you changed something while running project locally (like commenting lines in settings.py), you need to undo that. DEBUG variable value is, however, up to you.
- If you have git repository or want to create it, login to github and create your new repository, then add all files from project folder to it OR use GitHub Desktop to create and push all files into repository.
- Login to Heroku and create a new app (try not to forget its name).
- If you have files in remote github repository, in your app settings (on Heroku) open Deploy, scroll to Deployment method and choose GitHub. Then follow steps described there.
- If you have chosen to operate with Heroku CLI, also go to Deploy and scroll to Deployment method, make sure that you are on Heroku Git option and follow steps described there.
- Congratulations! Your site should be online. To visit it, scroll up on heroku and press Open app button.
This chapter will cover required steps to run tests in this project.
-
You should complete all steps necessary to deploy project locally, including downloading the source code.
-
While you are in the root folder, run next command:
py manage.py collectstatic -
Now you can run this command to run all tests:
py manage.py test -
To view tests, locate tests.py file in the page folder.