Thursday, October 25, 2018

Django - Start Guide

Django's primary goal is to ease the creation of complex, database-driven websites. Django emphasizes reusability and "pluggability" of components, less code, low coupling, rapid development, and the principle of don't repeat yourself.

Python is used throughout, even for settings files and data models. Django also provides an optional administrative create, read, update and delete interface that is generated dynamically through introspection and configured via admin models. 


In this below section we will learn to start basic server based website.

1.Install Virtual environment & Django:
   
  Go to command prompt and run pip install virtualenv  to install virtual environment 
  after that run pip install django  to finally install Django.

 
2. Create Folder : lets create a folder name Django Pro under which we need to run command prompt to tun pip freeze command to check the version of Django

C:\Django Pro>pip freeze
beautifulsoup4==4.6.0
Django==2.1.2
get==1.0.0
post==1.0.0
public==1.0.0
pytz==2018.5
query-string==1.0.0
request==1.0.0
selenium==3.11.0
virtualenv==16.0.0



3.Run Django: Now run following command to create sub directories under Django pro folder
   C:\Django Pro>django-admin.py startproject trydjango18

 now you will be able to see all new folder created by above command .

C:\Django Pro>dir
 Volume in drive C has no label.
 Volume Serial Number is 2E8B-D19A

 Directory of C:\Django Pro

10/20/2018  05:09 PM    <DIR>          .
10/20/2018  05:09 PM    <DIR>          ..
04/07/2018  05:58 PM    <DIR>          Include
10/20/2018  05:04 PM    <DIR>          Lib
10/20/2018  05:05 PM                59 pip-selfcheck.json
10/20/2018  05:05 PM    <DIR>          Scripts
10/20/2018  05:04 PM    <DIR>          tcl
10/20/2018  05:09 PM    <DIR>          Src
               1 File(s)             59 bytes
               7 Dir(s)  43,012,898,816 bytes free



4. Run manage.py  : Just to Src ( name folder in my case)  and  run 

    C:\Django Pro\src>python manage.py

5. Run server: In order to do so just run below command on terminal /cmd prompt

  C:\Django Pro\src>python manage.py runserver

You will get :

C:\Django Pro\src>python manage.py runserver
Performing system checks...


System check identified no issues (0 silenced).

You have 15 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.
October 20, 2018 - 17:10:55
Django version 2.1.2, using settings 'trydjango18.settings'
Starting development server at http://127.0.0.1:8000/    ------> Your Django ip address
Quit the server with CTRL-BREAK.
[20/Oct/2018 17:11:09] "GET / HTTP/1.1" 200 16348
[20/Oct/2018 17:11:09] "GET /static/admin/css/fonts.css HTTP/1.1" 200 423
[20/Oct/2018 17:11:09] "GET /static/admin/fonts/Roboto-Regular-webfont.woff HTTP/1.1" 200 80304
[20/Oct/2018 17:11:09] "GET /static/admin/fonts/Roboto-Light-webfont.woff HTTP/1.1" 200 81348
[20/Oct/2018 17:11:09] "GET /static/admin/fonts/Roboto-Bold-webfont.woff HTTP/1.1" 200 82564
Not Found: /favicon.ico
[20/Oct/2018 17:11:09] "GET /favicon.ico HTTP/1.1" 404 1977



  6. Admin Web Access : Just enter above IP address on your browser.


Congratulations you are on Django first web interface.



No comments:

Post a Comment

JOB in 2019

Automated - Digital One o One Meetings- An Idea

                                            Automated - Digital One o One Discussion                                                       ...