BeWell Blog is a full stack Django project that runs on Heroku.
- As a website user, I can:
- I can view a paginated list of posts so that I can choose which post I want to view.
- I can click on a post so that I can read the full text.
- I can create and register an account so that I can comment on a post.
- I can view comments on an individual post so that I can read the conversation.
- I can click on the About link so that I can read about the site.
- I can choose between different categories so that I can view posts in category that interests me the most.
- As an authenticated website user, I can:
- I can comment on a post so that I can say what I think and engage in a conversation.
- I can modify or delete my comments.
- I can view comments on an individual post so that I can read the conversation.
- As a website superuser, I can:
- I can view comments on an individual post.
- I can create draft posts so that I can finish writing the content later.
- I can create or update the about page content so that it is available on the site.
- I can create, read, update and delete posts.
- I can approve or disapprove comments so that I can filter out inappropriate or insulting comments.
The Agile Methodology was used to plan this project. This was implemented through Github and the Project Board which can be seen here - BeWell Blog User Stories
- To provide users with a simple, easy to navigate and visually pleasing website.
- To provide a website with
- To allow users to interact with the website by commenting.
BeWell Blog was designed to be a simple website that evokes a sense of tranquility, relaxation, and peacefulness. The aim was to create a soothing atmosphere for users visiting a website. I decided to stick with the neutral colour palette to match the idea behind the blog and maintain a nice visual contrast when viewing the site. Colours used are whitesmoke for the body, also silver, #373938, #dbd7d2, #5d9857, #8d9292, #2d3636, #363535, #fefefe rgb(255, 250, 250) and rgb(250, 250, 250). Bootstrap 5 native font stack was utilised.
-
All photographs used on the blog are from Pexels.com
-
All posts on the page are from Talkspace
- It is the landing page of the website which user can see first when the site loads. The homepage displays the latest 6 posts.
-
The site navigation is done through the navigation bar at the top of each page & this is consistant throughout the website.
-
The navigation bar at the top of each page is sticky to allow access to the navigation at any time.
-
Options on the navigation bar change depending on whether the user is logged in or not, or is an admin/staffuser or not.
-
When a regular user is visiting they can view and read a post onthe post detail page.
-
When an authenticated user is logged in they can also comment on a post.
-
If a comment is submitted this will have to be approved by an Admin user before it is displayed on the site.
- To see all posts on a paginated page click the blog logo or home button.
- To see categories for posts click the Category menu in the navbar and click on selected category in a dropdown menu. All post belonging to chosen category will be displayed.
- Superusers or staffusers are able to managae the posts and categories on the backend.
-
User Profile feature and Admin functionality on the frontend.
-
Social login to allow the user to signup using Facebook or Google
-
Password reset on the users profile page
- Gunicorn
As the server for Heroku - Cloudinary
Was used to host the static files and media - Dj_database_url
To parse the database URL from the environment variables in Heroku - Psycopg2
As an adaptor for Python and PostgreSQL databases - Summernote
As a text editor - Allauth
For authentication, registration, account management - Crispy Forms
To style the forms - Whitenoise
For static CSS on Heroku
- Manual Testing results here
The project was deployed via Heroku, and the live link can be found here: BeWell Blog
This project was developed utilising the Code Institute Template for Gitpod.
Before deploying to Heroku pip3 freeze > requirements.txt was used to add all dependencies for deployment and created the Procfile with web: gunicorn cocktailnerd.wsgi.
Created .slugignore with /documentation, README.md & TESTING.md as paths to ignore in Heroku as I don't want the documentation to upload to Heroku.
This project was deployed to Heroku using the Heroku CLI details below
- Login To use the CLI you must log in to your Heroku account. To do this you will need to enter the command heroku login -i in the terminal. It requires the email and password you used to sign up. If you have enabled multi-factor authentication (a recommended security practice) then instead of your password you need an API key. To get the API key go to your account settings and scroll down to the section ‘API Key’. Click reveal and copy that, then paste it into the password prompt.
- Creating A Heroku App Now that you are logged in, the first thing is to create a new app. Heroku creates a URL based on your app name, so it must be unique not only on your account, but across the whole site. You may need to try a few different names. To create an app use the following command, where myapp is the name of your app.
-
Here the app heroku-cli-example has been created with an output of the website URL. It also displays and sets the git remote repository which will be used to deploy. By default the region will be set to the US. If you would prefer a server based in the EU then you can specify the region with the flag EU
-
When you push code to Heroku it will look at the repository contents to decide how to build the project. One of the factors taken into consideration is the package file. With a Python project the standard file is a requirements.txt file, which will have the list of packages needed to run the project. If this file is present it will build the project using the Python buildpack.
-
It is also possible to specify the buildpack manually. More information about buildpacks can be found in the documentation. To check the buildpack for the project you can enter heroku buildpacks in the terminal.
- Run this command pip3 install pip3 install 'django<4' to install django.
- Added these libraries:pip3 install dj_database_url psycopg2,pip3 install dj3-cloudinary-storage
- Created requirements.txt file where I can save all the libraries I've installed:pip3 freeze --local > requirements.txt
- To create my project typed this command:django-admin startproject cocktailnerd
- To create my app:python3 manage.py startapp cocktailapp
- To make this app work, Into the setting.py file inside INSTALLED_APPS added cocktailapp
- To migrate changes typed this command:python3 manage.py migrate
- To run the test if the project is working python3 manage.py runserver
- When deploying for the first time on Heroku, you must first register with Heroku.
- Create your project name and location.
- To add Database into the app, Locate in the Resources Tab, Add-ons, search and add 'Heroku Postgres'
- Copy DATABASE_URL value, by going into the Settings Tab, click reveal Config Vars, Copy Text
- In your workspace Create new env.py file.
- Import os library:import os
- Set environment variables:os.environ["DATABASE_URL"] = "Heroku DATABASE_URL"
- Add in secret key:os.environ["SECRET_KEY"] = "mysecretkey"
- Add Secret Key to Config Vars in Heroku settings:SECRET_KEY, "mysecretkey"
- Add env.py file to the settings.py file:import osimport dj_database_urlif os.path.isfile("env.py"):import env
- Remove the insecure secret key and replace - links to the SECRET_KEY variable on Heroku:SECRET_KEY = os.environ.get('SECRET_KEY')
- Comment out the old DATABASES variable in setting.py file and add this instead:DATABASES = { 'default': dj_database_url.parse(os.environ.get("DATABASE_URL"))}
- Save all files and Make Migrations:python3 manage.py migrate
- Make account with Cloudinary To get static and media files.
- From Cloudinary Dashboard, Copy your CLOUDINARY_URL:
- Add Cloudinary URL to env.py file:os.environ["CLOUDINARY_URL"] = "cloudinary://************************"
- Add Cloudinary URL to Heroku Config Vars:"cloudinary://************************"
- Temporalliy add DISABLE_COLLECTSTATIC inside the heroku config Vars:DISABLE_COLLECTSTATIC, 1
- Add Cloudinary Libraries to settings.py installed apps:INSTALLED_APPS = ['cloudinary_storage', 'django.contrib.staticfiles', 'cloudinary']
- In the settings.py file under the STATIC_URL = 'static/' add:
STATICFILES_STORAGE = 'cloudinary_storage.storage.StaticHashedCloudinaryStorage'
STATICFILES_DIRS = [os.path.join(BASE_DIR, 'static'), ]
STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles')- Place under the BASE_DIR line in settings.py:TEMPLATES_DIR = os.path.join(BASE_DIR, 'templates')
- Change the templates directory to TEMPLATES_DIR Place within the TEMPLATES array:TEMPLATES = [{'DIRS': [TEMPLATES_DIR],],},},]
- Add Heroku Hostname to ALLOWED_HOSTS:ALLOWED_HOSTS = ["project4-cocktail-nerd.herokuapp.com", "localhost"]
- Create 3 new folders on the root directory: media, static, templates
- Create Procfile needed for Heroku on the root directory and inside the file add this:web: gunicorn dentist.wsgi
- Before deploying on heroku make sure: DEBUG = False Remove DISABLE_COLLECTSTATIC from the config vars.
- Created .slugignore with /documentation, README.md & TESTING.md as I don't want the documentation to upload to Heroku.
- Click Enable Automatic Deploys for automatic deployment when you push updates to Github.
- Select the correct branch for deployment from the drop-down menu and click Deploy Branch for manual deployment.
If you want to make changes to the repo without affecting it, you can make a copy of it by 'Forking' it.
- Log in to your GitHub account
- Navigate to the repository HERE
- Select the 'Fork' button in the top right corner of the page (under your account image)
- The repo has now been copied into your own repos and you can work on it in your chosen IDE
- If you have any suggestions to make regards to the code to make the site better, you can put in a pull request
- Log in to your GitHub account
- Navigate to the Repository HERE
- Select the 'Code' button above the file list on the right had side
- Ensure HTTPS is selected and click the clipboard on the right of the URL to copy it
- Open a new workspace in GitPod
- In the bash terminal type 'git clone [copy url here from step 4]'
- Press enter - the IDE will clone and download the repo
- Log in to your GitHub account
- Navigate to the Repository HERE
- Select the 'Code' button above the file list on the right had side
- Select 'Open with GitHub Desktop'
- If you haven't already installed GitHub desktop application - you will need to follow the relevant steps to do this
- The repo will then be copied locally onto your machine
- Log in to your GitHub account
- Navigate to the Repository HERE
- Select the 'Code' button above the file list on the right had side
- Select 'Download Zip'
- Once you have the Zip downloaded, open it with your prefered file decompression software
- You can then drag and drop the files from the folder into your chosen IDE or view/edit them on your local machine
- If you want to create a web-app from the repo please follow the instructions in "Project Deployment"
-
Code Institute "I think therefore I blog" walkthrough helped me understand and setup the base code for BeWell Blog.
-
Posts are from Talkspace
-
Images used on the website are from Pexels:
- https://www.pexels.com/photo/flexible-woman-doing-scorpion-yoga-asana-7592436/
- https://www.pexels.com/photo/photo-of-a-woman-sitting-on-the-bed-while-covered-by-a-white-blanket-6951509/
- https://www.pexels.com/photo/silhouette-of-man-standing-on-sandy-terrain-3876401/
- https://www.pexels.com/photo/woman-sitting-on-brown-stone-near-green-leaf-trees-at-daytime-1234035/
- https://www.pexels.com/photo/selective-focus-photography-of-person-using-iphone-x-1542252/
- https://www.pexels.com/photo/a-judge-holding-a-paper-6077356/
- https://www.pexels.com/photo/woman-wearing-gray-blazer-writing-on-dry-erase-board-1181534/
- https://www.pexels.com/photo/matchsticks-on-the-yellow-surface-6837562/
- https://www.pexels.com/photo/person-lying-on-bed-covering-white-blanket-271897/
- https://www.pexels.com/photo/positive-young-african-american-lady-holding-light-bulb-in-hand-on-gray-background-3973059/
- https://www.pexels.com/photo/grayscale-portrait-of-woman-594421/
- https://www.pexels.com/photo/woman-practicing-yoga-3822191/
- https://www.pexels.com/photo/man-showing-distress-3777572/
- https://www.pexels.com/photo/women-practicing-yoga-3822164/
-
Structure of this README.md file was inspired by former Code Institute student's README.md, which is the best, most detailed README file I have seen so far. Thank you to Artcuddy for making it available to other students.









