ویرگول
ورودثبت نام
مهران میرزایی
مهران میرزایی
خواندن ۱ دقیقه·۳ سال پیش

How to install Django


To find out which version installed:

python -V

Install VirtualEnv:

pip install virtualenv python -m pip install --user virtualenv

Add and activate Virtualenv to Project:

python -m venv env .\env\Scripts\activate

To install django :

python -m pip install django

To check django:

python -m django-admin

To make a django project:

django-admin startproject config .

To run django project:

python manage.py runserver
python manage.py runserver 0.0.0.0:8080

To add application to project:

django-admin startapp <app-name>

To create a view add these codes in app>views.py:

from django.shortcuts import render from django.http import HttpResponse def index(request): return HttpResponse(&quotThis is django ! &quot)

Create app>urls.py:

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

Edit Project>urls.py:

from django.contrib import admin from django.urls import path,include
urlpatterns=[
path('admin/' , admin.site.urls), path('app/',include('app.urls')),
]


howtodjangoinstallpython
MikroTik Certified Consultant (MTCNA , MTCWE)
شاید از این پست‌ها خوشتان بیاید