Skip to content

Portfolio website, created using Django Web Framework with a PostgreSQL Database. The initial project idea came from a Django LinkedIn Learn course.

License

Notifications You must be signed in to change notification settings

TobiAdeniyi/django-portfolio-website

Repository files navigation

Contributors Forks Stargazers Issues MIT License LinkedIn

Django Portfolio Website

Table of Contents
  1. About This Project
  2. Getting Started
  3. Development
  4. Deployment
  5. Acknowledgements

About This Project

Product Name Screen Shot

Description:

In this project I will be showing my step by step process for building a Django Portfolio Website. Django—an open-source web framework that's designed on top of Python—can help you quickly bring your website ideas to life. I plan to illustrate my undestanding of Django for web development, by building my own website from the ground up. I will create a database, design the layout for your website, and add and update URL paths. Then I will connect my Django portfolio website to Postgres, and add static files, URLs and more.

Key objectives:

  • Setting up URLs in Django project
  • Creating models in Django
  • Connecting Django project to Postgres
  • Adding static images
  • Designing the layout for website
  • Creating object views
  • Updating URL paths

Getting Started

Here are some instructions on how to get this project up and running. First you will need some some prerequsites to manage a local virtual environment. Bellow is a list of 'Bare Minimums' you need to follow along with this project.

Here is how we install them:

  • Check if python and pip are installed

    python --version
    python -m pip --version
  • If python is notinstalled, you can download it from the Python website. If pip is not installed, run the following command or check out

    python get-pip.py pip==21.0.1

Installations:

  1. Create a directory for the project, then download or clone project the project into the directory by simply run the following command in your terminal

    mkdir project
    cd project
    git clone https://github.com/TobiAdeniyi/django-portfolio-website
  2. Install and activate the virtual environment, using pip as so

    python -m venv portfolio_website_environment
    source portfolio_website_environment/bin/activate
    python -m pip install requirements.txt
    pip list

    Or alternatively, if you have Anaconda installed, create and activate a virtual environment, using conda, by running the following command

    conda env create -f environment.yml
    conda activate portfolio_website_environment
    conda env list
  3. TODO

Development

TODO

Saving Environment Variables

Take private environment veriables from SECRET_KEY in setings.py, and store it as a environment variable that is export and unset when virtual environment is activated. This is done by creating a subdirectory file

cd $CONDA_PREFIX
mkdir -p ./etc/conda/activate.d
mkdir -p ./etc/conda/deactivate.d
touch ./etc/conda/activate.d/portfolio_website_env.sh
touch ./etc/conda/deactivate.d/portfolio_website_env.sh

Then edit ./etc/conda/activate.d/portfolio_website_env.sh and ./etc/conda/deactivate.d/portfolio_website_env.sh respectively, as so

#!/bin/sh

export SECRET_KEY='secret-key-from-settings'
export DATABASE_URL='databse-url-from-heroku' # $(heroku config:get DATABASE_URL -a your-app)
export SECRET_PASSWORD='postgresql-password-from-postgresql'
#!/bin/sh

unset SECRET_KEY
unset DATABASE_URL
unset SECRET_PASSWORD

For more information check out Saving environment variables in the Anaconda Docs, and Connecting Heroku to Postgres in Heroku docs.

Ensure to replace SECRET_KEY value in setings.py, for example

import os

SECRET_KEY = os.environ.get("SECRET_KEY")

Deployment

TODO

Instilations

pip install gunicorn install django-heroku

Procfile

echo "web: gunicorn portfolio.wsgi" >> Procfile

requirements.txt

python -m pip freeze > requirements.txt

environment.yml

conda env export > environment.yml

Export important variable to heroku

heroku config:set SECRET_KEY=$SECRET_KEY
heroku config:set DATABASE_URL=$DATABASE_URL
heroku config:set SECRET_PASSWORD=$SECRET_PASSWORD

HEROKU CONFIG

python manage.py collectstatic

PGUSER=postgres PGPASSWORD=SECTRET_PASSWORD
heroku pg:push postgresqldb DATABASE_URL --app heroku-app-name

Run locally

heroku local
git add .
git commit -m "Done :exclamation:"
git push heroku main
heroku open

Acknowledgements

About

Portfolio website, created using Django Web Framework with a PostgreSQL Database. The initial project idea came from a Django LinkedIn Learn course.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages