DJANGO - a web frame work of python (part-1)

Image result for django python
third blog of series is       here:https://codexmaze.blogspot.com/2019/06/django-web-framework-of-pythonpart-3.html

Django is python framework for web development. This framework is now in use by big companies as google , instagram etc. The reason is python and other reason is a set pattern of django.
This will be a three blog series to tell you what is Django , where to start and basic command lines with some snippets.
Now we first start with installation of django.But first you have to check python is install in your windows or not.
OPEN "WINDOW POWERSHELL" and type "python --version".If it is found then python is install.
Now proceed further for installation of Django.

Install PIP:

PIP is a package manager for Python that uses the Python Package Index to install Python packages. PIP will later be used to install Django from PyPI. If you’ve installed Python 3.4, pip is included so you may skip this section.
Open a command prompt and execute easy_install pip. This will install pip on your system. This command will work if you have successfully installed Setuptools.
Alternatively, go to http://www.pip-installer.org/en/latest/installing.html for installing/upgrading instructions.

Install Django:

Django can be installed easily using pip.
In the command prompt, execute the following command: pip install django. This will download and install Django.
After the installation has completed, you can verify your Django installation by executing django-admin.py --version in the command prompt.

Creating a project

If this is your first time using Django, you’ll have to take care of some initial setup. Namely, you’ll need to auto-generate some code that establishes a Django project – a collection of settings for an instance of Django, including database configuration, Django-specific options and application-specific settings.
From the command line, cd into a directory where you’d like to store your code, then run the following command:
$ django-admin.py startproject mysite

This will create a mysite directory in your current directory, which look like above snippet.you will get a directory with bunch of files and a setting.py file.
 When you are done with creating directory what will be the next step , the next step will be get your server.The coolest thing about Django that it comes with a server of it self.

The development server:

Let’s verify your Django project works. Change into the outer mysite directory, if you haven’t already, and run the following commands:
$ python manage.py runserver
You’ll see the following output on the command line:
Performing system checks...

0 errors found
February 24, 2017 - 15:50:53
Django version 1.7, using settings 'mysite.settings'
Starting development server at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
You’ve started the Django development server, a lightweight Web server written purely in Python. We’ve included this with Django so you can develop things rapidly, without having to deal with configuring a production server – such as Apache – until you’re ready for production.
Now’s a good time to note: don’t use this server in anything resembling a production environment. It’s intended only for use while developing. (We’re in the business of making Web frameworks, not Web servers.)
Now that the server’s running, visit http://127.0.0.1:8000/ with your Web browser. You’ll see a “Welcome to Django” page, in pleasant, light-blue pastel. It worked!
Changing the port
By default, the runserver command starts the development server on the internal IP at port 8000.
If you want to change the server’s port, pass it as a command-line argument. For instance, this command starts the server on port 8080:
$ python manage.py runserver 8080
If you want to change the server’s IP, pass it along with the port. So to listen on all public IPs (useful if you want to show off your work on other computers), use:
$ python manage.py runserver 0.0.0.0:8000
Full docs for the development server can be found in the runserver reference.
Automatic reloading of runserver
The development server automatically reloads Python code for each request as needed. You don’t need to restart the server for code changes to take effect. However, some actions like adding files don’t trigger a restart, so you’ll have to restart the server in these cases


Before you go any further it becomes very important to clear your concept about apps . I just hate that how now a days every thing is called an app . Apps are basically a part of a project . For example : If we are creating a music project then it will have many sections such as ALBUMS, SONGS etc.
then every single section is called app.

Projects vs. apps
What’s the difference between a project and an app? An app is a Web application that does something – e.g., a Weblog system, a database of public records or a simple poll app. A project is a collection of configuration and apps for a particular Web site. A project can contain multiple apps. An app can be in multiple projects.


In the above image we have a music directory (basically folder) inside the website directory,that is an app.when we will start server and go to  " http://127.0.0.1:8000/music " that page will be an app of music project. Hope that this made your concept clear.

In the next blog i will explain what are the meaning of models , views ,and urls , it will be only over view that will help you to understand that how it actually works.

-- @maze runner







Comments

Varun said…
This is beneficial for that person which is starting from basic level. Good job brother
Ankita Kumari said…
This is an informative post on web design and development. Looking forward to read more.
Web Design and Development Company India

Popular posts from this blog

Amazon Web Services

Google Code-In mentorship experience :)

Hacker Rank all java and python problem solutions