STEP 1: Create "fossils_project" folder. Open PowerShell and enter the following commands:

python -m venv virt
virt/scripts/activate
pip install django
django-admin startproject fossils
cd fossils
python manage.py migrate
python manage.py createsuperuser
ni .gitignore
ni .env
python manage.py startapp app_fossils
pip install python-decouple
pip freeze > requirements.txt
python manage.py runserver

STEP 2: Update the .env file.

Navigate to https://djecrety.ir/, generate a new secret key and paste it inside the .env file:

SECRET_KEY = ‘_your_generated_key_here_’

STEP 3: Create folders in the root (fossils) directory.

app_fossils
    templates
        app_fossils
media
static
    app_fossils
        css
        images
        js
    project
templates

STEP 4: settings.py

Add imports:

import os
from decouple import config    

Secret key:

SECRET_KEY = config('SECRET_KEY')

Allowed hosts:

ALLOWED_HOSTS = ['127.0.0.1', 'localhost']

Add your app to the installed apps (the name will be the same as the class name found in apps.py):

INSTALLED_APPS = [
…
'app_fossils.apps.AppFossilsConfig',
…
]

Activate project level 'templates' directory:

TEMPLATES = [{
  ...
  'DIRS': [os.path.join(BASE_DIR, 'templates'), ],
  ...
}]

Activate project level 'static' directory:

STATICFILES_DIRS = (os.path.join(BASE_DIR, 'static'),)

File uploads:

MEDIA_ROOT = os.path.join(BASE_DIR, 'media')
MEDIA_URL = 'media/'

Redirects:

LOGIN_REDIRECT_URL = 'homepage'
LOGOUT_REDIRECT_URL = 'homepage'

STEP 5: urls.py - main project level: include & admin

Media in production: + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
from django.contrib import admin
from django.conf import settings
from django.conf.urls.static import static
from django.urls import path, include
from django.http import HttpResponse

def restricted(request):
    return HttpResponse("Access to the admin area is restricted.")


urlpatterns = [
    path('admin/', restricted),
    path('secret_admin/', admin.site.urls),
    path("", include("app_fossils.urls")),
] + static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

STEP 6: urls.py - app level (create the file first)

from django.urls import path
from django.http import HttpResponse

def urls_test(request):
    return HttpResponse("Urls set up correctly")

urlpatterns = [
    path('', urls_test),
]

STEP 7: Run project

After completing the setup process, you can now run the server by executing the command 'python manage.py runserver'. Once the server is running, you can access the web application by navigating to the following URLs in your web browser:
http://127.0.0.1:8000/
http://127.0.0.1:8000/admin
http://127.0.0.1:8000/secret_admin    

STEP 8: Create base.html and navbar.html files.

Navigate to the "templates" folder located directly in the root directory of your project and reate two new files: "base.html" and "navbar.html".

navbar.html

Go to the Bootstrap website https://getbootstrap.com/, navigate to the "docs" section and locate the "navbar" component. Copy the provided HTML code and paste it into the "navbar.html" file.

base.html

Favicon: Obtain a favicon and save it in the "static\project" folder under your project's root directory. You can use websites such as https://icon-icons.com/ to obtain a favicon or convert a .jpg image to an .ico file using https://icon-icons.com/.

If you include a tag referencing a favicon, but the corresponding favicon image file is not present in the static files, you may encounter an unexpected issue preventing you from disabling Django's debug mode when deploying your project to a live environment.

Bootstrap: Navigate to the Bootstrap website and obtain the current CSS and JS links.

STEP 9: Homepage (template/view/url + use base&navbar)

Step 9.1: Inside app_fossils -> templates -> app_fossils create home.html file
Step 9.2: views.py
def home(request):
    return render(request, 'app_fossils/home.html')
Step 9.3: urls.py

At this point we can delete the urls_test function and and the corresponding path.
Next we have to import views: from . import views and create a new URL pattern:

from django.urls import path
from app_fossils.views import *

urlpatterns = [
    path('', home, name='homepage'),
]
Step 9.4: Use the new url: open navbar.html and add the new ‘homepage’ url

STEP 10: GitHub

Step 10.1: Update the .gitignore file

# Ignore database files
*.db
*.sqlite3

# Ignore media files
/media/

# Ignore compiled Python files
*.pyc
__pycache__/

# Ignore environment variables file
.env

# Ignore local settings file
local_settings.py

# Ignore IDE configuration files
.idea/
.vscode/

# Ignore migration files
*/migrations/*.py
*/migrations/*.bak
*/migrations/*.swp
*/migrations/*.pyc
*/migrations/__pycache__/

# Ignore log files
*.log

# Ignore message files created by Django's internationalization framework
*.pot

# Ignore SQLite database files
db.sqlite3

# Ignore media files that are uploaded to the server
media

# Ignore virtual environment directories
.venv/
env/
venv/
ENV/
virt/
virtual/
env.bak/
venv.bak/

# Ignore secret key file
secret_key.txt

# Ignore system files
.DS_Store
Thumbs.db
Step 10.2: Create a new repository
cd..
virt/scripts/activate
cd fossils
git init
git add .
git commit -m "first commit"
git branch -M main
git remote add origin https://github.com/_replace_with_your_username_/fossils.git
git push -u origin main

Going forward, whenever you make changes to your code, you can use the following commands to push the updates to your main branch on GitHub:

git add .
git commit -m "my_commit_message"
git push origin main

STEP 11: User authentication - Django AllAuth

Install Django allauth: pip install django-allauth

settings.py: Add 'allauth' and 'allauth.account' to INSTALLED_APPS:

INSTALLED_APPS = [
  # ...
  'django.contrib.sites',
  'allauth',
  'allauth.account',
  'allauth.socialaccount',
  # ...
]

settings.py: Add the following:

AUTHENTICATION_BACKENDS = [
  'django.contrib.auth.backends.ModelBackend',
  'allauth.account.auth_backends.AuthenticationBackend',
]

SITE_ID = 1
ACCOUNT_EMAIL_VERIFICATION = 'mandatory'
ACCOUNT_EMAIL_REQUIRED = True

urls.py - project level: include the allauth URLs:

urlpatterns = [
  # ...
  path('accounts/', include('allauth.urls')),
  # ...
]

Run database migrations: python manage.py migrate