0% found this document useful (0 votes)
2 views3 pages

Django Commands

The document provides a guide on using Django commands for setting up a virtual environment, starting a new project, and creating applications. It includes commands for activating the environment, installing Django, running the server, and performing basic ORM operations such as creating and retrieving objects. Additionally, it outlines the structure for defining URL paths for views in a Django application.

Uploaded by

Rishika Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views3 pages

Django Commands

The document provides a guide on using Django commands for setting up a virtual environment, starting a new project, and creating applications. It includes commands for activating the environment, installing Django, running the server, and performing basic ORM operations such as creating and retrieving objects. Additionally, it outlines the structure for defining URL paths for views in a Django application.

Uploaded by

Rishika Sharma
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

DJANGO COMMANDS

--to create env


-python –version
-python -m venv myenv
-python -m venv sysenv

-sysenv\Scripts\activate
-pip install Django
-python -m django --version

-to start a new project


-django-admin startproject my_firstproject

-to go inside the folder


-cd my_firstproject
python manage.py runserver # to run project

-to get out of folder


-cd ../
CTRL + C TO break the server

-To create one more folder in code


-python manage.py startapp myapp

from testapp.views import home,about,contact,service


path('admin/', admin.site.urls),
path('home',home),
path('about',about),
path('contact',contact),
path('service',service)

ORM
----Create object in orm
Model.objects.create(field_name=123)
ob=Model(field_name=123)
ob.save()

---read operation:
Model.objects.all() (All records are store)
Model.objects.get(pk_name=131) (single object return)
rec=Model.objects.get(pk_name=131) (single object return) {{rec.field_name}}
Model.objects.filter(pk_name) ##[(), () , ()]
Model.objects.filter(pk_name) ##[(), () , ()]

You might also like