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.
- 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
Bootstrap 4.0 is used for the frontend.
Django 2.1 with Python 3.7 is used for the backend.
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.
conda create --name env_pyblog python=3.7
conda activate env_pyblog
pip install -r requirements.txt
It is installed while creating the venv.
pip install -r requirements.txt
This will install all of the required packages we selected within the requirements.txt file.
- 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
pip install flake8, autopep8, pillow, django-crispy-forms
Included in requirements.txt - external installation not required.
SQLite database is used for development. It is configured automatically by Django.
With Postgres, create a database named pyblogdb
createdb pyblogdb
Make sure to include the database credentials in env_file.py
From the project directory to run the server, execute:
conda activate env_pyblog
python manage.py runserver
In order to run tests, navigate to the project folder and run the following commands:
pytest test_app.py
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.
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.
For special commands and detailed note refer to the following links: