This application was a project from Udemy course. The original Github page is here.
AutoMax is a website where people can can to see the available cars. They can also create their own listings for other people to buy.
The images for the car is from here.
source venv/bin/activate
deactivate
django-admin help
django-admin startproject <<name-of-project>> .
python manage.py startapp <<name-of-app>>
python manage.py runserver
python manage.py makemigrations
python manage.py migrate
python manage.py createsuperuser
python manage.py collectstatic
SECRET_KEY DJANGOAPPMODE (Debug for local dev and Prod for deployment) USEDEBUGDB (True in local False in prod)
EMAIL_HOST_USER EMAIL_HOST_PASSWORD
DBNAME DBUSER DBPASSWORD DBHOST DBPORT
BUCKETEER_AWS_ACCESS_KEY_ID BUCKETEER_AWS_SECRET_ACCESS_KEY BUCKETEER_AWS_REGION BUCKETEER_BUCKET_NAME
Implementing it in base.html
django.contrib.messages (already installed)
- Import environ package
import environ
- Initialize environ
env = environ.Env()
andenv.read_env()
create .env
file to manage environment variable which is left out in git repository.
This .env is used for local development
Use service called "mailgun"
- Go to Heroku to set mailgun as resource
- Go to mailgun and get credentials
- set settings:
EMAIL_BACKEND=
EMAIL_HOST=
EMAIL_PORT=
EMAIL_USER_TLS=
EMAIL_HOST_USER = env('EMAIL_HOST_USER')
EMAIL_HOST_PASSWORD = env('EMAIL_HOST_PASSWORD')
- when new profile image is selected, the image shown should change as well
- see how the bio in the profile can have larger text area
We use whitenoise
to serve static file.
Once you install it you should add following to Middleware:
MIDDLEWARE = [
'django.middleware.security.SecurityMiddleware',
"whitenoise.middleware.WhiteNoiseMiddleware",
...
]
Then in the settings:
STATIC_ROOT = BASE_DIR / 'static'
STATICFILES_STORAGE = "whitenoise.storage.CompressedManifestStaticFilesStorage"
heroku login
heroku git:remote -a <name-of-app-in-heroku>
Create following files:
- Procfile
- web: gunicorn automax.wsgi
- requirements.txt
- runtime.txt
- should indicate python runtime (python-3.9.14 for example or whatever python runtime used for the virtual machine)
git add .
git commit -m "..."
git push heroku main