- Create a directory smartnotes
- Go to that directory and initalize venv
python -m venv .
- Activate the environment
source bin/activate
pip install django
Django-admin startproject smartnotes .
- Create an empty repository in git and perform below steps in local
git init .
#add .gitignore
git add .
git commit -m "initial commit"
git remote add origin https://github.com/hariiisai/smartnotes.git
git branch -M main
git push -u origin main
- Create a first app called home
django-admin startapp home
and add 'home' in installed apps of 'settings.py' - Create 'home.html' and render 'url:home' to this html by view.home
- Include 'home.urls' in main url file
- Before creating users we need to setup database connection so users will be stored
- To do this we can simply run
python manage.py migrate
to apply built-in migrations for app(s): admin, auth, contenttypes, sessions. - Create a admin user now
python manage.py createsuperuser
- Created a authorised page which can be viewed by loggedin users
- Create a new app notes
django-admin startapp notes
and add it in 'setting.py' - Create a model 'notes' in 'models.py' of notes folder
- To make a relation of this model, we need to make migrations
python manage.py makemigrations
- Perform actual migration
python manage.py migrate
# The table 'notes' will be created in database - Register you model in 'admin.py'
- Now you can manage 'notes' model from admin page
- Create a logic(view) to display all notes in 'notes_list.html' and add 'notes.url' in main urls
- Create a logic to disaply single note
- Rewrite the functions into classes
- Change the pointing in urls file
- Create a new folder 'static' in main project folder and have sepearte folders for css,images...
- Add the STATICFILES_DIRS in 'settings.py'
- Create a style.css and load static files in html pages
- Created a 'base.html' and extends it to other html pages
- Create a logic to add new notes
- Do not forget to add csrf_token in forms
- With forms we can add validations, labels, and much more --Not implemeted
- No need to mention action for this form, if mention it will be hardcodes as action ={% url 'notes/list' %}
- Added notes update,edit,delete options
- Added login, logout and signup options
For details about Django built-in views, check out https://ccbv.co.uk/