- Python 3.9.5
- PostgreSQL 14.1
- Clone the project with
git clone https://github.com/upy/bootcamp.git ecommerce-django && cd ecommerce-django
- Create virtual environment with
virtualenv --python=3.9 .venv
and activate it withsource .venv/bin/activate
- Enter the ecommerce folder with
cd ecommerce
- Install dependencies with
pip install -r requirements.txt
- Create server, database and superuser with the Postgresql. (If you want to do database operations with a gui, you can additionally use pgAdmin.)
- Execute the migrate process with
python manage.py migrate
- Fill in the contents of the
.env.dist
file and copy it as.env
- SECRET_KEY in the .env file can be generated with the following command.
python -c 'from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())'
- DEBUG variable should be True only during project development.
- The parameters in the DATABASE_URL variable in the .env file are the superuser username and password, the IP and port specified for the server, and the database name, respectively.
In order for the changes to be created in the form of SQL Tables, the migrate operation must be performed. The migration process consists of the following two steps.
- Creating migration files:
python manage.py makemigrations
- The resulting files create the necessary tables in SQL database:
python manage.py migrate
In order to use the site in different languages, it is necessary to create localization files. The localization process consists of the following three steps.
- Creating the file with the phrases to be translated for the preferred language:
python manage.py makemessages -l <language>
. Language ex.: "en", "tr". - Translation of phrases in the file ending with ".po" located in the
locale
folder. - Compile the file with the translated phrases:
python manage.py compilemessages
In order to enter the admin panel, it is necessary to create a super user. It can be done with the following command: python manage.py createsuperuser
. Then type email and password.
Run python manage.py runserver ip_you_want:port_you_want
and go to http://ip_you_want:port_you_want
from the browser.
Ex.: Run python manage.py runserver 0.0.0.0:5252
and go to http://0.0.0.0:5252
from the browser.
Note: If ip and port are not specified, it will work on the default ip(127.0.0.1) and port(8000). Make sure that the ip address entered in "ip_you_want" is in ALLOWED_HOSTS variable in the
.env
file.
docker build -t web:latest . docker build -t registry.heroku.com/APP_NAME/web .
heroku login
heroku create APP_NAME
heroku config:set SECRET_KEY='secret_key' ALLOWED_HOSTS='APP_NAME.herokuapp.com' TIME_ZONE='UTC' -a APP_NAME
heroku container:login
docker push registry.heroku.com/APP_NAME/web
heroku container:release -a APP_NAME web
heroku run python manage.py migrate -a APP_NAME
heroku run python manage.py compilemessages -a APP_NAME
heroku run python manage.py createsuperuser --email=your@email.com -a APP_NAME
heroku logs --tail