Skip to main content

Python Tutorial

Python Tutorial Coming Soon


Download Python


For Window


Download

For Mac Os X


Download

How to check Python are install & check version also

  1. Step - Type Window+R  button on your Computer or PC.
  2. Step- Type cmd/CMD and press enter. A black screen window opened called Command Prompt.
  3. Step- Type PYTHON/Python/python.

How To Intall Django FrameWork in Django

Note :- For installing django we need to install python latest version and all packages also. Links are given above. Your computer and PC are should connected to internet.

  1. Step- Open command prompt type pip install virtualenv
  2. Step- pip install django



How to create a Project in Python

Note:- create project on desktop to easily find. Below Bookcollection is an project name, You can choose any name which you want.
  1. Step- Open command prompt type cd desktop and press enter.
  2. Step-  Type django-admin startproject Bookcollection and press enter.
Verify that Bookcollection named project created on desktop. In this project two file are created automatically. Firstone is Bookcollection and secondone is manage. Manage file extention are saved with ( .py ). Open Bookcollection here four file are created automatically.
      
  1.         __init__
  2.     settings
  3.    urls
  4.    wsgi

All file are saved with ( .py ) extention.



Now we need to run this project for what stuff are in it. Python are server based language. So we need server for run our project. Servers are not free but Python solve our problem, Python can run on local server in our computer or PC.

Run our project on server

  1. Step- Open command prompt type cd desktop and press enter.
  2. Step- Type cd Bookcollection and press enter.
  3. Step- Type python manage.py migrate and press enter
  4. Step- Type python manage.py runserver and press enter



After perform migration these all are shown.

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 admin.0002_logentry_remove_auto_add... OK
  Applying admin.0003_logentry_add_action_flag_choices... OK
  Applying contenttypes.0002_remove_content_type_name... OK
  Applying auth.0002_alter_permission_name_max_length... OK
  Applying auth.0003_alter_user_email_max_length... OK
  Applying auth.0004_alter_user_username_opts... OK
  Applying auth.0005_alter_user_last_login_null... OK
  Applying auth.0006_require_contenttypes_0002... OK
  Applying auth.0007_alter_validators_add_error_messages... OK
  Applying auth.0008_alter_user_username_max_length... OK
  Applying auth.0009_alter_user_last_name_max_length... OK

  Applying sessions.0001_initial... OK

After perform runserver these all are shown
Performing system checks...

System check identified no issues (0 silenced).
August 10, 2018 - 19:28:19
Django version 2.1, using settings 'f.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CTRL-BREAK.




Now command prompt open instructions. Here 127.0.0.1:8000 local server created in your computer. Do not close this command prompt window. If you close this window server are also closed, and we can't run our project.
  1. Step- Type 127.0.0.1:8000 in your browser url tab.

The install worked successfully! Congratulations! These message are shown on your browser front. Done our project are run.








How to create admin panel 
Note:- open second command prompt window.


Type 127.0.0.1:8000/admin/ in browser url tab for admin pannel


  1. Step- Open command prompt 
  2. Step- Type cd desktop and press enter.
  3. Step- Type cd Bookcollection and press enter.
  4. Step- Type python manage.py createsuperuser and press enter. 

Username (leave blank to use 'pavilion'): username
Email address: user@gmail.com
Password: admin12345 (in command prompt password are blanked) password are not show here.
Password (again):admin12345

Fill all the data in the form are given like below and click on login button



How to create python app 

we are creating app for connecting our project , we need to create app in project file so.
  1. Step- Open command prompt and type cd desktop and press enter.
  2. Step- Type cd Bookcollection and press enter
  3. Step- Type django-admin startapp Home

app are created in Bookcollection project file 

How to connect Python project to Python app or Create class in python 

  1. step- Open models.py to your project and type is code

from django.db import models

# Create your models here.

class Books(models.Model):
title = models.CharField(max_length=80)
author = models.CharField(max_length=100)
isbn = models.CharField(max_length=30, unique=True)
url = models.URLField()
publisher = models.CharField(max_length=100)
def __str__(self):
  return self.title+',  '+self.author+',  '+self.isbn+', +self.url+',  '+self.publisher

2. step- Open admin.py and type this code 

from django.contrib import admin
from .models import Books

# Register your models here.
admin.site.register(Books)
3. step- Open settings.py and type this code in 34 line
'Home.apps.HomeConfig',

Now save it all and open cmd type 
  1. Step- open cmd and type cd desktop and press enter
  2. Step- Type cd Bookcollection and press enter
  3. Step- Type python manage.py makemigrations Home press enter
  4. Step- Type python manage.py migrate and press enter
  5. Step- Type python manage.py runserver and press enter
 our project run on local server type 127.0.0.1:8000/admin to login admin panel. Here a class was created named Bookss.Here we can add list of some books.

Now create a urls.py file in Home app and type this code
from django.contrib import admin
from django.urls import path,include

from django.contrib import admin
from django.urls import path,include

urlpatterns = [
    path('admin/', admin.site.urls),
path('Home/',include('Home.urls')),
]
Note:-type this above code in Home urls don't confuse

Comments

Post a Comment

Popular posts from this blog

CSS Tutorial step by step

CSS   Introduction Cascading Style Sheets   (CSS) is a   style sheet language   used for describing the   look and formatting   of a document written in a markup language . While most often used to style   web pages   and user interfaces written in   HTML   and   XHTML . CSS is a cornerstone specification of   the web   and almost all web pages use CSS style sheets to describe their presentation. CSS is designed primarily to enable   the separation of document content from document presentation , including elements such as the   layout ,   colors , and   fonts .   This separation can improve content   accessibility , provide more flexibility and control in the specification of presentation characteristics, enable multiple pages to share formatting, and reduce complexity and repetition in the structural content (such as by allowing for   table less web design ). It   obvia...

TypingPad

TypingPad is a simple  text editor  for  Microsoft Windows  and a basic text-editing program which enables computer users to create documents. It was first released  in 2018, and has been included in  versions of  Microsoft Windows .  Features TypingPad  is a common text-only ( plain text ) editor. The resulting files—typically saved with the  .txt  extension—have no format tags or styles, making the program suitable for editing system files to use in a  DOS  environment and, occasionally, source code for later  compilation or  execution , usually through a  command prompt . It is also useful for its negligible use of system resources; making for quick load time and processing time, especially on under-powered hardware. TypingPad supports both left-to-right and right-to-left based languages. Historically,  TypinfPad offers only the most basic text manipulation functions, such as finding text. ...

XML Engine Tutorial

Overview • XML basics and Libname engine introduction • Effectively reading XML files • Introduction to the XML Mapper •Writing XML files using SAS • Common problems processing XML files What is XML? • XML is a set of rules used for defining &modeling structures • XML is extensible & customizable  Its greatest strength  Its greatest weakness XML Basics- Well Formed Files Document has a single root element • Elements nest properly • No tag omission (close what you open) • Attributes must be quoted • Special characters < > and & must always be escaped XML Basics- Well Formed Files • XML is case sensitive Anatomy of an XML file <?xml version="1.0"?> <workorder priority="high"datedue="09/30/2001"> <submitter> <name first="Jennifer" last="Kyrnin" /> <email>html.guide@about.com</email> <account number="11001100" /> Container or root X...