Django Project

Django Project

Let's start to use it. Each web app you want to build in Django is called a project; and a project is a collection of apps. A software is a series of MVT-based code files. Let's say we want to build a website as an example, the website is our project and applications are the form, news, communication engine. This design makes it easier to transfer an application between projects since it is independent of each task.

Create a Project

 where we want our project to be built.

$ django-admin startproject myproject1

This will create a "myproject1" folder with the following structure –

Myproject1/
    manage.py
    myproject1/
       __init__.py 
       settings.py
       urls.py
       wsgi.py 

 

The “myproject1” folder is just our project container, it actually contains two elements –

1-manage.py- This file is typical to our local django-admin project to interact with our project via cmd prompt (start server development, sync db ...). We can use the code ? to get a complete list of commands accessible via manage.py

$ python manage.py help

2- The “myproject1” subfolder ? This folder is the actual python package of our project. It contains four files –

    _init_py- This folder is used as a package only for python.

   settings.py- As the name indicates itself, our project settings.

   urls.py- It is where we define the mapping between URLs and views. All links of your project and the function to call.

wsgi.py- To deploy a project over WSGI(The goal is to provide a relatively simple but robust interface that can accommodate all (or most) interactions between a Web server and a Web application.)

 

Setting Up Our Project

Our project is set up in the subfolder myproject1/settings.py. Following are some important options you might need to set before –

Debug=True

This option is uses to set if our project is in debug mode or not. Debug mode collect more information regarding project's error. It will Never set it to ‘True’ for a live project. However, this has to be set to ‘True’ only if we want the Django light server to serve static files.

Note-Do it only in the development mode.

 

DATABASES = {
    'default': {
       'ENGINE': 'django.db.backends.sqlite3',
       'NAME': 'database.sql',
       'USER': '', 
       'PASSWORD': '',
       'HOST': '',
       'PORT': '', 
    }
 } 

Database is set in the ‘Database’ dictionary. Django is also in support of

  • MySQL (django.db.backends.mysql)
  • PostGreSQL (django.db.backends.postgresql_psycopg2)
  • Oracle (django.db.backends.oracle)
  • MongoDB (django_mongodb_engine)
  • NoSQL DB

Now that your project is created and configured make sure it's working ?

$ python manage.py runserver

We will get something like this after running  above code –

Validating models...
 0 errors found
 November 06, 2019 – 04:09:50 
 Django version 1.6.11, using settings 'myproject1.settings'
 Starting development server at http://127.0.0.1:8000/ 
 Quit the server with CONTROL-C. 

Related Topics

Django CSRF

Django is a high-level python based web framework. Django is open source and free to use for all. Django provides many features to web developers like scalability, security, rapid development,...

4 minutes read.

Django Project

Django Project Let's start to use it. Each web app you want to build in Django is called a project; and a project is a collection of apps. A software is a series of...

3 minutes read.

Django Pagination

Django is an open-source free to use python based web framework. Django provides many inbuilt tools for web developers to provide rapid web development. One of these tools is pagination....

4 minutes read.

Django vs Laravel

Django Overview Django is a Python Programming Open Source framework for web development. It was released in 2008 and was developed by two web developers named Adrian Holovaty and Simon Willison....

4 minutes read.

Django All Auth

For any web application, user registration and authentication are the essential parts. In Django, there are several applications like django-registration-redux to perform these tasks, but the major drawback is that...

6 minutes read.

Django Logging

Every application developed has some bugs and errors. It is the responsibility of the developers to maintain the application by making it bug-free and error-free. To debug the application code...

5 minutes read.

Django Stack

Django is a popular Python web application framework that adheres to the "batteries-included" tenet. Batteries-guiding included idea is that common functionality for creating web applications should be provided with the...

5 minutes read.

Django Authentication

Django is an open-source free to use web framework which is based on Python. Django uses Model-View-Template as its architecture. The final version of Django was released in 2008. Django...

4 minutes read.

Django Filters

Django is a high-level python based web framework. Django is mostly used as a backend engine for websites. Nowadays, every website communicates to a database to fetch all the information...

3 minutes read.

Django Celery

Django is a python-based web framework. It is an open-source and free-to-use framework. Django uses the Model View Template architecture. Django provides many functionalities to web developers. One of these...

3 minutes read.

Django Model Fields

In Django, if we want to store the information about anything, we use Models. It contains various fields about the data. Generally, each model represents a database where all the...

4 minutes read.

Django ORM

Django is a Python web framework that enables easy and quick web development. Django has a handy and powerful feature called Django Object Relational Mapper, also known as Django ORM,...

3 minutes read.

Django REST Framework

Django REST Framework (DRF)is an open-source, powerful, and flexible toolkit used to build RESTful web APIs. It is built upon the Django framework. DRF increases the development speed. Django and...

4 minutes read.

How to Uninstall Django from cmd

Python is an interactive and more accessible language than any other programming language. The python programming language uses a variety of libraries to perform the operations in a faster way....

3 minutes read.

Django Tutorial

Django Introduction It is a web application framework written in a python programming language. It based on the MVT( Model View Templet) design pattern. It takes a short time to build an application...

2 minutes read.

Django Template System

Django Template System Django allows Python and HTML to be divided, the Python goes into views, and HTML goes into templates. Django relies on the render feature and the language of the Django Model...

5 minutes read.

Django Forms

Django is a Python Programming Open Source framework for web development. It was released in 2008 and was developed by two web developers named Adrian Holovaty and Simon Willison. It...

3 minutes read.

Django Image Upload

Django is a python based web framework that uses Model View Template as its architecture. Django provides really quick web development with its functionalities. While we are building a website,...

3 minutes read.

Django DRF

Django Rest Framework, which is also referred to as DRF, is a very powerful application to build RESTful APIs in a Django application. DRF uses the Django framework. Similar to...

3 minutes read.

Uses of Django

Django is a free and open-source Python-based web framework, which offers great functionalities to its users. Django was developed in 2003, and the final version was released in 2008 by...

3 minutes read.