Django Portfolio Project
Django Portfolio Project
In PyCharm Create new project [ file -> newfile -> ( provide file name) Create ]
Go to ip which showing or type localhost:8000 this url manually in any brower, if you see the below
image then its installed successfully.
Inside templates -> jobs, Create homepage.html file and type <h1>Login360</h1>
Model: It’s a python class that used to create tables in our database.
Going to Create table named Job with two columns image (ImageField) and Summary (CharField).
So, no configuration changes required to store sqlite3 DB, so skip this page if you going to work on
default sqlite3 DB
But to work with different database engine we need to install that database engine and need to
config our settings.py, refer below details to install and config postgresql
Go to https://www.enterprisedb.com/downloads/postgres-postgresql-downloads
1. Choose PostreSQL latest version and Windows x86-64 and click Download Now.
2. Install the downloaded file
3. Choose a password
4. Keep the default port of 5432.
5. Uncheck the Stack Builder option and click Finish
6. In your Windows search bar, search for pgadmin and launch it.
7. Right-click PostgreSQL in Servers and choose Connect
8. Right-click Databases and choose Create-> Database…
In python terminal give the below command to work with postgresql in python.
makemigrations: Based on our model.py, it will create .py file inside migrations folder,
migrate: To create/update our Database, based on the created .py file in migrations folder.
It will automatically create the below 0001_initial.py and make table as we mentioned.
Give username, skip email by pressing Enter. Provide password for admin site login
To add our Job model in views.py, inside views.py type below code.
Then in homepage.html
Then run server using python manage.py runserver , you will see added job summary there.
To make homage to show in initial url , we need to change the url patterns as below in urls.py
(highlighted text doesn’t have any space inbetween)
Procedure to reset migration/delete migration: (when migrations got corrupted due to some
unnecessary change, you can use this)