Sign in
Log inSign up

INTRODUCTION TO DJANGO

Bassey Glory's photo
Bassey Glory
·Aug 21, 2020·

4 min read

It’s now the end of the She Code Africa Mentoring program Cohort 2, it has been a wonderful journey so far and I learnt so much and right now I will be sharing some with you. You’re super excited right? The following are the topics covered in this article:

• What is django?

• Application of django

• Advantages of django

• Getting started with django

WHAT IS DJANGO?

Django is a high-level Python web framework that allows you to develop web pages rapidly, it is free and open-source and very fast in developing web pages. Developers find it easy to stroll with the web page creation as this framework helps in the easy creation of pages with data arranged properly and repositories managed with high relevance.

APPLICATION OF DJANGO

Secure

Django provides a secure way to manage user accounts and password, it helps developers avoid many common security mistakes by providing a framework to protect the website automatically.

Maintainable

Django code is written using design principles and patterns that encourage the creation of maintainable and reusable code. In particular, it makes use of the Don't Repeat Yourself (DRY) principle so there is no unnecessary duplication, reducing the amount of code. Django also promotes the grouping of related functionality into reusable "applications" and, at a lower level, groups related code into modules (along the lines of the Model View Controller (MVC) pattern).

Versatile

Django can be (and has been) used to build almost any type of website — from content management systems and wikis, through to social networks and news sites. It can work with any client-side framework, and can deliver content in almost any format (including HTML, RSS feeds, JSON, XML, etc).

Portable

Django is written in Python, which runs on many platforms. That means that you are not tied to any particular server platform, and can run your applications on many flavours of Linux, Windows, and Mac OS X.

ADVANTAGES OF DJANGO

  1. It is a Python Language: As mentioned Django is written in Python. Python language is simple to learn and easy to implement. Python manages more in fewer lines with large libraries.
  2. Django and Python: Django and Python are core solutions for Fintech Companies in Silicon Valley, IT giants, Blue chip companies, and the Internet of things.
  3. Extensive Support Libraries: It provides libraries that include string operations, web services, operating system interfaces, and standard protocol.
  4. Scalable: To handle the heaviest traffic, it is used to meet busiest site traffic demands. It allows you to take different actions regarding scalability such as running separate servers for database and even use clustering or load-balancing to distribute the application on multiple servers.

  5. Administrative Interface: The administration interface provided by Django is simple to create and one of the key advantages using a framework. It gives you a fully-featured admin interface. For e.g

class Interface(models.Model): interface_title = models.CharField(max_length=50) some_other_text = models.CharField(max_length=100) some_boolean_value = models.BooleanField() admin.site.register(Interface)

GETTING STARTED WITH DJANGO

Creating your Django Application

A Django project creates a collection of settings including database configuration, and specific options and also application specific settings default in the project.

Steps to Create an application

Create a directory where you want to store your project and cd into that directory and install django.

install.PNG

Create a directory where you want to store your project and cd into that directory and run the following command

start.PNG

If you look at your directory, the following structure will be created

Cap.PNG

manage.py: Lets you interact with this Django project in different ways.

init.py: Tells the python interpreter that the directory should be considered as a python package. This file is mostly empty.

settings.py: It is the configuration file.

urls.py: Include all URL declaration for the Django project and table of contents of Django powered site.

wsgi.py: It is the entry point for WSGI compatible web servers to serve your projects and deploy with WSGI.

If you want to check, that your project is running you can check it using the following command

$ python manage.py runserver

How Django make your work easy?

This follows a pythonic way that is “Simple is better than complex”. One of the python packages that is stored inside the site-packages directory of your Python Installation with other important Python packages like Numpy, Scipy, Pillow etc.

A simple way to verify it to installed and if you are able to import it into your project:

Cut.PNG

It provides you with everything that is necessary to develop a full-fledged application. It offers with built-in templating using HTML, URL routing, ORM (Object Relational Mapping), session management etc. It also offers a number of useful tools for SEO. Using the SEO framework, the developers can reduce page loading time using cached templates and by CSS, JavaScript compression. There is also a tool to manage robots.txt.Django CMS capabilities very much exceed expectations of professional SEO specialists.

So far we have discussed django, it’s application, advantages and how to get started with django. I hope you find this article helpful.

Hassle-free blogging platform that developers and teams love.
  • Docs by Hashnode
    New
  • Blogs
  • AI Markdown Editor
  • GraphQL APIs
  • Open source Starter-kit

© Hashnode 2024 — LinearBytes Inc.

Privacy PolicyTermsCode of Conduct