Created
May 30, 2018 08:22
-
-
Save tmvinoth3/c90d8c76e292925479cdc8c144be2ef4 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
pip install virtualenv | |
virtualenv vir_env | |
#To activate virtual environment | |
vir_env\Scripts\activate | |
django-admin startproject django_practice | |
django-admin startapp myApp | |
#Include myapp in settings.py | |
#Make sure debug off in production | |
python manage.py makemigrations myapp | |
#sql commands for models | |
python manage.py sqlmigrate myapp 0001 | |
#apply migration | |
python manage.py migrate | |
#Set up credentials for admin site | |
python manage.py createsuperuser | |
#configure view in urls.py in myapp folder | |
#configure myapp/urls.py to urls.py | |
from django.conf.urls import url | |
python manage.py createsuperuser | |
#Shell same like REPL | |
python manage.py shell | |
#To exit from shell | |
exit | |
#insert value in database | |
obj = Board(name = "testname", description = "testdescription") | |
obj.save() | |
#or | |
obj = Board.objects.create(name = "testname", description = "testdescription") | |
#Get all objects | |
Board.objects.all() | |
Board.objects.get(id=1) | |
#Load static to use bootstrap | |
{%load static%} | |
(Donts) | |
#Make sure use model = ModelName (not model:ModelName) in forms.py | |
#Don't put comma(,) in GCBV | |
#GCBV | |
model | |
fields | |
template_name | |
pk_url_kwarg | |
context_object_name | |
#Important: Include enctype <form method="post" enctype="multipart/form-data"> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment