Portfolio website for Developer using Python, Django, HTML, SCSS
-
Install Python 3 or above.
-
Create virtual environment for project and project dependencies so that it won't affect other projects. It is best practice to provide a dedicated environment for each Django project you create.
py -m venv project-name
Please note: Everytime you start project after closing activate your virtual environment for project.
Please note: Everytime you start project after closing IDE, system or project folder you have to/need to activate your virtual environment
path_to_virtual_env_folder\script\activate.bat
on windows andsource path_to_virtual_env_folder\bin\activate
on linux, otherwise dependency/packages install above will not work or there will some module not found errors. -
Install Project Dependencies
To install all the dependencies/packages used in project.
pip install -r requirements.txt
-
Installing PostgreSQL 12 Go to PostgreSQL Download and follow installation instructions. Adding user and granting all access on the database to the user.
Adding user: For more information
CREATE USER yourusername WITH PASSWORD 'youruserpassword' CREATEDB;
Adding database: For more information
CREATE DATABASE yourdatabasename;
Providing access to that user on db: For more information
grant all privileges on database yourdatabasename to yourusername;
-
Adding config file
Add file name appsettings.json in project root directory.
After adding appsettings.json copy/paste the below settings
{ "DATABASE_USER": "", "DATABASE_NAME": "", "DATABASE_PASSWORD": "", "DATABASE_PORT": "", "DATABASE_HOST": "", "DATABASE_ENGINE": "django.db.backends.postgresql", "EMAIL_HOST": "", "EMAIL_PORT": "", "EMAIL_HOST_USER": "", "EMAIL_HOST_PASSWORD": "", "SECRET_KEY": "^j5q4(halslig96013*d!fj1)w)ee&9ryyrymrm@t+1e8n_cs&t7a3!ksutuu", "EMAIL_RECEIVER" : "" }
After adding this to appsettings.json modify these fields:
- DATABASE_USER - Your database username of PostgreSQL.
- DATABASE_NAME - Name of the database to be used for project.
- DATABASE_PASSWORD - Database user (DATABASE_USER) password
- DATABASE_PORT - Database port on which it is running
- DATABASE_HOST - Host will be the ip address where postgresql is running can be a virtual machine or docker address or localhost (127.0.0.1).
- DATABASE_ENGINE - In case of postgresql engine name will be: django.db.backends.postgresql This application have contact us section, the below settings are for that
- EMAIL_HOST - The host to use for sending email. In my case I used Gmail (smtp.gmail.com)
- EMAIL_PORT - Port to use for the SMTP server defined in EMAIL_HOST. Since I used gmail it was 587.
- EMAIL_HOST_USER - Username to use for the SMTP server defined in EMAIL_HOST. For gmail it was my *******@gmail.com Email Id
- EMAIL_HOST_PASSWORD - Password to use for the SMTP server defined in EMAIL_HOST. This setting is used in conjunction with EMAIL_HOST_USER when authenticating to the SMTP server. In my case I have generated app password for gmail you can follow the steps here Sign in with App Passwords or follow this video of Corey Schafer Django Tutorials
- SECRET_KEY - A secret key for a particular Django installation. This is used to provide cryptographic signing, and should be set to a unique, unpredictable value.
- EMAIL_RECEIVER - Receiver's email address.
We have setup our dev machine now it is time to run project Since Django has its own inbulit models and admin site, we are going to run some commands in the project root directory:
- Run
python manage.py makemigrations
The above command will create migrations in each folder will latest data model changes - Run
python manage.py migrate
The above command will run the migration scripts and create table in database - Now we need to add superuser(admin) for handling the data from admin site
Run
python manage.py createsuperuser
this will create a admin user for the website. Enter the following details and remember them:- Username
- Password
- Run
python manage.py runserver
to run the website
If everything is in order you see a website running on http://127.0.0.1:8000 or http://localhost:8000
Now go to admin panel of website navigate to http://127.0.0.1:8000/admin .
Add some data from admin panel,and see it live on your homepage i.e. (http://127.0.0.1:8000 or http://localhost:8000)
You can build the scss using following command
python manage.py sass .\main\static\main\scss\ .\main\static\main\css\
I followed this video of Corey Schafer
https://youtu.be/Sa_kQheCnds?list=PL-osiE80TeTtoQCKZ03TU5fNfx2UY6U4p
I would like to thank RyanFitzgerald for his devportfolio template.
I have used this template https://github.com/RyanFitzgerald/devportfolio