0% found this document useful (0 votes)
54 views

Django Server Setup

The document shows the steps to setup a Django project - creating a virtualenv, installing Django using pipenv, starting a Django project using startproject, running the development server locally and exposing it, applying database migrations, and creating a superuser.

Uploaded by

nirmal
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
54 views

Django Server Setup

The document shows the steps to setup a Django project - creating a virtualenv, installing Django using pipenv, starting a Django project using startproject, running the development server locally and exposing it, applying database migrations, and creating a superuser.

Uploaded by

nirmal
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 4

django-admin startproject mysite.

python manage.py runserver


python manage.py runserver 0.0.0.0:8000

python manage.py create

####PS D:\PROJECTS\Django 101> python -V


Python 3.9.8
####PS D:\PROJECTS\Django 101> pip install pipenv
Requirement already satisfied: certifi in
c:\users\nirmal\appdata\local\programs\python\python39\lib\site-packages (from
pipenv) (2021.10.8)
Requirement already satisfied: setuptools>=36.2.1 in
c:\users\nirmal\appdata\local\programs\python\python39\lib\site-packages (from
pipenv) (58.1.0)
Requirement already satisfied: pip>=18.0 in
c:\users\nirmal\appdata\local\programs\python\python39\lib\site-packages (from
pipenv) (21.3.1)
Requirement already satisfied: virtualenv in
c:\users\nirmal\appdata\local\programs\python\python39\lib\site-packages (from
pipenv) (20.10.0)
Requirement already satisfied: virtualenv-clone>=0.2.5 in
c:\users\nirmal\appdata\local\programs\python\python39\lib\site-packages (from
pipenv) (0.5.7)
Requirement already satisfied: backports.entry-points-selectable>=1.0.4 in
c:\users\nirmal\appdata\local\programs\python\python39\lib\site-packages (from
virtualenv-nv) (1.1.1)
Requirement already satisfied: platformdirs<3,>=2 in
c:\users\nirmal\appdata\local\programs\python\python39\lib\site-packages (from
virtualenv->pipenv) (2.4.1)
Requirement already satisfied: distlib<1,>=0.3.1 in
c:\users\nirmal\appdata\local\programs\python\python39\lib\site-packages (from
virtualenv->pipenv) (0.3.4)
Requirement already satisfied: six<2,>=1.9.0 in
c:\users\nirmal\appdata\local\programs\python\python39\lib\site-packages (from
virtualenv->pipenv) (1.16.0)
Requirement already satisfied: filelock<4,>=3.2 in
c:\users\nirmal\appdata\local\programs\python\python39\lib\site-packages (from
virtualenv->pipenv) (3.4.2)
####PS D:\PROJECTS\Django 101> pipenv install Django
Creating a virtualenv for this project...
Pipfile: D:\PROJECTS\Django 101\Pipfile
Using C:/Users/NIRMAL/AppData/Local/Programs/Python/Python39/python.exe (3.9.8) to
create virtualenv...
[=== ] Creating virtual environment...created virtual environment
CPython3.9.8.final.0-64 in 9481ms
creator CPython3Windows(dest=C:\Users\NIRMAL\.virtualenvs\Django_101-4HgnXrkC,
clear=False, no_vcs_ignore=False, global=False)
seeder FromAppData(download=False, pip=bundle, setuptools=bundle, wheel=bundle,
via=copy, app_data_dir=C:\Users\NIRMAL\AppData\Local\pypa\virtualenv)
added seed packages: pip==21.3.1, setuptools==58.3.0, wheel==0.37.0
activators
BashActivator,BatchActivator,FishActivator,NushellActivator,PowerShellActivator,Pyt
honActivator
Successfully created virtual environment!
Virtualenv location: C:\Users\NIRMAL\.virtualenvs\Django_101-4HgnXrkC
Creating a Pipfile for this project...
Installing Django...
Adding Django to Pipfile's [packages]...
Pipfile.lock not found, creating...
Locking [dev-packages] dependencies...
Locking [packages] dependencies...
Building requirements...
Resolving dependencies...
Success!
Installing dependencies from Pipfile.lock (06f36b)...
================================ 0/0 - 00:00:00
To activate this project's virtualenv, run pipenv shell.
Alternatively, run a command inside the virtualenv with pipenv run.
####PS D:\PROJECTS\Django 101> pipenv shell
Launching subshell in virtual environment...
Windows PowerShell

Try the new cross-platform PowerShell https://aka.ms/pscore6


####PS D:\PROJECTS\Django 101> pipenv shell.
Usage: pipenv [OPTIONS] COMMAND [ARGS]...
Try 'pipenv -h' for help.

Error: No such command 'shell.'.

Did you mean one of these?


shell
####PS D:\PROJECTS\Django 101> pipenv shell
Shell for C:\Users\NIRMAL\.virtualenvs\Django_101-4HgnXrkC already activated.
Name: Django
Version: 4.0.1
Summary: A high-level Python web framework that encourages rapid development and
clean, pragmatic design.
Home-page: https://www.djangoproject.com/
Author: Django Software Foundation
Author-email: [email protected]
Location: c:\users\nirmal\.virtualenvs\django_101-4hgnxrkc\lib\site-packages
####PS D:\PROJECTS\Django 101> exit
####PS D:\PROJECTS\Django 101> pipenv shell
Launching subshell in virtual environment...
Windows PowerShell
Copyright (C) Microsoft Corporation. All rights reserved.

Try the new cross-platform PowerShell https://aka.ms/pscore6

PS D:\PROJECTS\Django 101> django-admin startproject mysite.


CommandError: 'mysite.' is not a valid project name. Please make sure the name is a
valid identifier.
####PS D:\PROJECTS\Django 101> django-admin startproject mysite .
####PS D:\PROJECTS\Django 101> dir

Directory: D:\PROJECTS\Django 101

Mode LastWriteTime Length Name


---- ------------- ------ ----
d----- 12-01-2022 00:56 mysite
-a---- 12-01-2022 00:56 684 manage.py
-a---- 12-01-2022 00:51 151 Pipfile

####PS D:\PROJECTS\Django 101> python manage.py runserver


Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly until you
apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
January 12, 2022 - 00:59:16
Django version 4.0.1, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
####PS D:\PROJECTS\Django 101> python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly until you
apply the migrations for app(s): admin, auth, contenttypes, sessions.
January 12, 2022 - 01:01:24
Django version 4.0.1, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[12/Jan/2022 01:01:24] "GET / HTTP/1.1" 200 10697
[12/Jan/2022 01:01:25] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
[12/Jan/2022 01:01:25] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1"
200 85692
[12/Jan/2022 01:01:25] "GET /static/admin/fonts/Roboto-Regular-webfont.woff
HTTP/1.1" 200 85876
[12/Jan/2022 01:01:25] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1"
200 86184
Not Found: /favicon.ico
[12/Jan/2022 01:01:25] "GET /favicon.ico HTTP/1.1" 404 2110
####PS D:\PROJECTS\Django 101> python manage.py runserver 0.0.0.0:8000
Watching for file changes with StatReloader
Performing system checks...
System check identified no issues (0 silenced).

You have 18 unapplied migration(s). Your project may not work properly until you
apply the migrations for app(s): admin, auth, contenttypes, sessions.
Run 'python manage.py migrate' to apply them.
January 12, 2022 - 01:02:25
Django version 4.0.1, using settings 'mysite.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CTRL-BREAK.

####PS D:\PROJECTS\Django 101> python manage.py migrate


Operations to perform:
Apply all migrations: admin, auth, contenttypes, sessions
Running migrations:
Applying contenttypes.0001_initial... OK
Applying auth.0001_initial... OK
Applying admin.0001_initial... OK
Applying sessions.0001_initial... OK
####PS D:\PROJECTS\Django 101> python manage.py runserver 0.0.0.0:8000
Watching for file changes with StatReloader
Performing system checks...

January 12, 2022 - 01:05:54


Django version 4.0.1, using settings 'mysite.settings'
Starting development server at http://0.0.0.0:8000/
Quit the server with CTRL-BREAK.
[12/Jan/2022 01:06:40] "GET / HTTP/1.1" 200 10697
[12/Jan/2022 01:06:40] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
[12/Jan/2022 01:06:40] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1"
200 85692
[12/Jan/2022 01:06:40] "GET /static/admin/fonts/Roboto-Regular-webfont.woff
HTTP/1.1" 200 85876
[12/Jan/2022 01:06:40] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1"
200 86184
Not Found: /favicon.ico
[12/Jan/2022 01:06:40] "GET /favicon.ico HTTP/1.1" 404 2110
PS D:\PROJECTS\Django 101> python manage.py runserver
Watching for file changes with StatReloader
Performing system checks...

System check identified no issues (0 silenced).


January 12, 2022 - 01:07:14
Django version 4.0.1, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.
[12/Jan/2022 01:07:17] "GET / HTTP/1.1" 200 10697
[12/Jan/2022 01:07:18] "GET /static/admin/css/fonts.css HTTP/1.1" 304 0
[12/Jan/2022 01:07:18] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1"
304 0
[12/Jan/2022 01:07:18] "GET /static/admin/fonts/Roboto-Regular-webfont.woff
HTTP/1.1" 304 0

####PS D:\PROJECTS\Django 101> python manage.py createsuperuser


Username (leave blank to use 'nirmal'):
Email address: [email protected]
Password:
Password (again):
This password is too short. It must contain at least 8 characters.
Bypass password validation and create user anyway? [y/N]: y
Superuser created successfully.
####PS D:\PROJECTS\Django 101> python manage.py runserver 0.0.0.0:8000

You might also like