Skip to content

thehimel/pyblog

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

54 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

PyBlog

The PyBlog is a blog app where users can register themselves to post articles and see each others posts. This project implements various important aspects of Django.

All backend code follows PEP8 style guidelines.

Features

  • Users
    • Account creation
    • Update the profile
    • Create, Read, Update, and Delete own posts
    • Read posts of other users
  • Admins
    • Read all models
    • Does have any access to sensitive data like passwords

Frontend

Bootstrap 4.0 is used for the frontend.

Backend

Django 2.1 with Python 3.7 is used for the backend.

Getting Started

Installing Dependencies

MiniConda

Download and install MiniConda from here.

It is used to create and manage the virtual environment. pip freeze > requirements.txt is used to create the dependency list.

Create Virtual Environment and Install Dependencies
conda create --name env_pyblog python=3.7
conda activate env_pyblog
pip install -r requirements.txt
Python 3.7

It is installed while creating the venv.

PIP Dependencies

pip install -r requirements.txt

This will install all of the required packages we selected within the requirements.txt file.

Key Dependencies

  • Django - A Python based web framework
  • pillow - A library to manage images in Django Apps
  • django-crispy-forms - A Library to integrate Django forms with Bootstrap
  • flake8 - Used for mainting the linting with VSCode
  • autopep8 - Used for few auto linting with VSCode
Installation

pip install flake8, autopep8, pillow, django-crispy-forms

Included in requirements.txt - external installation not required.

Database Setup

Development

SQLite database is used for development. It is configured automatically by Django.

Production

With Postgres, create a database named pyblogdb

createdb pyblogdb

Make sure to include the database credentials in env_file.py

Running the server

From the project directory to run the server, execute:

conda activate env_pyblog
python manage.py runserver

Tests

pytest

In order to run tests, navigate to the project folder and run the following commands:

pytest test_app.py

Deployment

We are using Heroku for deployment.

  • Install heroku in your machine.
  • Login to heroku
heroku login
  • Create an app
heroku create appname
  • Create 2 databases by running the following command twice. One for application and other one to use during the test.
heroku addons:create heroku-postgresql:hobby-dev --app appname
  • Check configuration variables in Heroku
heroku config --app appname

Note down the db variables and include them in the setup.sh.

  • Initialize git in the project directory
git init
git remote add heroku https://git.heroku.com/appname.git
  • Push it to heroku
git add .
git commit -am "make it better"
git push heroku master

If there is any issue, use heroku restart to restart the app.

Author

Acknowledgements

This project is created while studying Django Full-Featured Web App by Corey Schafer in YouTube. Special thanks to Corey Schafer for creating such a nice course demostrating each part so beautifully.

Note

For special commands and detailed note refer to the following links:

About

A Blog Created with Python and Django

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published