Skip to content

πŸš€ Django Step-by-Step Learning Repository Welcome to the ultimate guide for mastering Django! This repository is designed to take you through Django's intricacies step by step, making the learning process smooth and enjoyable.

Notifications You must be signed in to change notification settings

engrshishir/Django-Portfolio

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation


πŸš€ Django Step-by-Step Learning Repository Welcome to the ultimate guide for mastering Django! This repository is designed to take you through Django's intricacies step by step, making the learning process smooth and enjoyable.

GitHub repo size GitHub last commit

Initial Project

  • Create a folder(anywhere you want)
  • open folder in vscode editor
  • open terminal
  • from right side of the terminal select command prompt ( by default it selected with powershell)
  • make a vertual environment : python -m venv venv
  • Activate virtual environment : venv\Scripts\activate
  • Install Django : pip install django
  • Create a django project : django-admin startproject app
  • Run project
    • Enter your project & run : python manage.py runserver
    • you can see your project run over : http://127.0.0.1:8000/
    • copy url and hit browser & enjoy your first Django run
  • Create a app inside project : django-admin startapp app
  • Configure project settings.py to configure our new app
    • Go to settings.py. Then inside INSTALLED_APPS = [] list, add 'app', which is your created appName
    • Create a templates foder inside project directory. Where app,manage.py,templaes ar in same lavel
    • Go to settings.py. Then nnside TEMPLATES = [] list, add 'DIRS': ['templates']
    • Inside templates folder create a index.html file & just write something, like Hello world in html file
      <!DOCTYPE html>
      <html lang="en">
      <head>
          <meta charset="UTF-8">
          <meta name="viewport" content="width=device-width, initial-scale=1.0">
          <title>Django App</title>
      </head>
      <body>
          <h1>Hello world</h1>
      </body>
      </html>
    • Now to connect app urls.py, with main project urls.py, create urls.py inside app
      from django.urls import path
      
      urlpatterns = [
          
      ]
    • Go to app views.py & create a function index
      def index(request):
          return render(request,'index.html')
    • Go to again app urls.py & include views index function for specific url
      from app import views
      from django.urls import path,include
      
      urlpatterns = [
          path('',include(views.index,name="index"))
      ]
    • Go to project urls.py & include app urls.py file
      from django.contrib import admin
      from django.urls import path,include
      
      urlpatterns = [
          path('admin/', admin.site.urls),
          path('',include('app.urls'))
      ]
    • Close & rerun server again. Your index.html file should see in the browser successfully

Authentication process

  • Create seperate app(Auth) inside project : django-admin startapp Auth. Make sure your venv is activated

Connect Django project with Mysql

  • install Xampp
  • Go to project settings.py and make database configuration as like bellow
    DATABASES = {
        'default': {
            'ENGINE': 'django.db.backends.mysql',
            'NAME' : 'travel', # Database name
            'USER' : 'root', # Database user name 
            'PASSWORD': '', # Database password 
            'HOST': 'localhost',
            'PORT': '3306' # Mysql port number
        }
    }
  • Run : pip install mysqlclient This command confirm your database settings

  • Go to project & run : python manage.py migrate. This command create, default django table inside database.

  • Create models to create custom table inside database.You should register models inside app/admin.py. Also add some settings in settings.py. Then run 2 commands : python manage.py makemigrations, python manage.py migrate


Here you can find Django's step-by-step working procedure. If it helps you, you should give me a star

About

πŸš€ Django Step-by-Step Learning Repository Welcome to the ultimate guide for mastering Django! This repository is designed to take you through Django's intricacies step by step, making the learning process smooth and enjoyable.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published