Skip to content

Tarik-Bhateja/ThaparSummerSchool_2k23

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

90 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ThaparSummerSchool_2k23 Cheat Sheet

Step1. Install , create and activate virtualenv

Step2. Start Django project

   django-admin startproject <project name>

Step3. Start django app

inside the project folder

  > cd <project name>
  > python manage.py startapp <app name>

Step4. configuring settings.py

Step4.1 Add app name to installed apps list

  > INSTALLED_APPS = [
  >    ....
  >  <app name>
  > ]

Step4.2 Give templates folder path and create folder

  > import os
  >
  > 'DIRS': [os.path.join(BASE_DIR,'templates')],

Step4.3 Give static folder path and create folder inside the app[important]

  > STATIC_URL = 'static/'
  > STATIC_ROOT = BASE_DIR / 'static'
  > STATICFILES_DIR = [os.path.join(BASE_DIR, 'static')]

Step5. Configuting the urls.py in project folder

  > from django.urls import path, include
  >
  > urlpatterns = [
  > ...
  > path('',include('members.urls'))
  > ]

Step6. Create and populate urls.py in app folder

  > from django.urls import path
  > from . import views
  > urlpatterns = [
  > ...
  > path('',views.index,name='index'),
  > ...
  > ]

Step7. Populate viwes.py in app folder

  > from django.shortcuts import render
  >
  >def index(request):
  >   #any operations you want to do
  >    return render(request,'graph.html')

Step8> Create and register model

in models.py of app

  > from pyexpat import model
  > from django.db import models
  >
  > class QUESTION(models.Model):
  >   q1=models.IntegerField(blank=False,default=9)

in admin.py of app

  > from <app name>.models import QUESTION
  > 
  > admin.site.register(QUESTION)

Step9. Collect Static files and Migrate database

  > python manage.py makemigrations
  > python manage.py migrate
  > 
  > python manage.py collectstatic

Step10. Create SuperUser

  > python manage.py createsuperuser

admin

Login by going to the prebuilt django admin panel at http://127.0.0.1:8000/admin/

adm

ad2

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published