CaraMcAvinchey / stem-and-leaf-blog

A plant care passion blog for my Full Stack Portfolio project. Built using Django and Bootstrap.
https://stem-and-leaf-blog.herokuapp.com/
2 stars 6 forks source link
bootstrap css django html javascript python

Stem & Leaf - A Plant Care Space for Beginners

Author

Cara McAvinchey

Project Overview

image

Table of Contents

UX

Project Goal

User Stories

Design Choices

Colors

image

Typography

image

Images/Icons

image

Animations

Responsiveness

Wireframes

Post List

image

Post Detail

image

Features/Structure

Navigation

Plant List

image image

Plant Detail

image image

Likes

image image

Comments

image image image image Screenshot 2022-12-30 at 14 19 16 image

Register

image

Login/Logout

image image image image

Footer

Error 404/403/500

image image image

Features for Future Development

Data Model

Screenshot 2023-06-08 at 19 30 04 Screenshot 2023-06-08 at 19 32 53 Screenshot 2023-06-08 at 19 33 52

Testing

Please refer to the TESTING.md file for all testing performed.

Technologies

Languages

Database

Frameworks

Libraries & Packages

Programs

Deployment

ElephantSQL

  1. Login to ElephantSQL, access the dashboard and create a new instance (input a name, choose tiny turtle, select a region).
  2. Return to the dashcoard, copy the URL.

Heroku

  1. Create a new app in Heroku, choose a unique name and region.
  2. Go to settings and add a new config var of DATABASE_URLpython with the value of the URL from ElephantSQL.
  3. Add host name of the Heroku app name to ALLOWED HOSTS in settings.py:
ALLOWED_HOSTS = ['{heroku deployed site URL here}', 'localhost' ]

GitHub/GitPod

  1. Create a new repository on GitHub, open a new workspace with GitPod.
  2. Install django pip3 install 'django<4python to install Django 3.2 the LTS (Long Term Support) version.
  3. Create a new project and run the server to see if the app has installed.
  4. Run migrations, create a super-user with a username, email and password.
  5. Install pip3 install dj_database_url==0.5.0 psycopg2 and freeze requirements pip freeze > requirements.txt
  6. Add import os and import dj_database_url to settings.py
  7. Connect the new database, paste in the ElephantSQL URL (do not commit at this stage):
 # DATABASES = {
 #     'default': {
 #         'ENGINE': 'django.db.backends.sqlite3',
 #         'NAME': os.path.join(BASE_DIR, 'db.sqlite3'),
 #     }
 # }

 DATABASES = {
     'default': dj_database_url.parse('your-database-url-here')
 }
  1. Ensure connection to the external database, run python3 manage.py showmigrations then run python3 manage.py migrate

    image
  2. Create a new superuser for the new database, same as above.

  3. Create an if else statement to setup development and external databases:

    if 'DATABASE_URL' in os.environ:
    DATABASES = {
      'default': dj_database_url.parse(os.environ.get('DATABASE_URL'))
    }
    else:
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.sqlite3',
            'NAME': os.path.join(BASE_DIR, 'db.sqlite3')
      }
    }
  4. Install pip3 install gunicorn and run pip freeze > requirements.txt

  5. Create a Procfile in the root directory and include web: gunicorn project_name.wsgi:applications

  6. Generate a SECRET_KEY, add it to Heroku config vars.

  7. Create env.py file (ensure it is included in .gitignore file) and add the SECRET_KEY & DATABASE_URL to environment variables:

    image
  8. Edit settings.py to the below:

    SECRET_KEY = os.environ.get('SECRET_KEY', ' ')
    DEBUG = 'DEVELOPMENT' in os.environ

    image

image
  1. Add, commit and push to GitHub.

  2. Go to Heroku, add DISABLE_COLLECT_STATIC = 1 to Heroku config vars.

  3. Connect the project to the GitHub repository using personal account login.

  4. Login to Cloudinary, copy the API Environmental variable to dashboard and add to env.py (see screenshot above) & to Heroku config vars:

image
  1. Add cloudinary to installed apps in settings.py, add static/media file settings:
image image
  1. Add template directories in settings.py, add Heroku host name to allowed hosts and add directory files:
image image image
  1. Go to settings in Heroku and perform a manual deployment and check for any issues.
  2. Go to Heroku settings, enable automatic deployments.

Credits

Media

Acknowledgements

Back to the beginning