Write a simple Django application

little bottle
Release: 2019-04-08 15:43:52
forward
2176 people have browsed it

There are many different web frameworks under Python, and Django is the most representative among the heavyweight players. Through this tutorial, we'll walk you through creating a basic voting application. It will be made up of two parts: a public site that will let people view and vote, and an administrative site that will let you add, modify, and delete votes.

$ django-admin startproject mysite
mysite/
    manage.py
    mysite/
        __init__.py
        settings.py
        urls.py
        wsgi.py
Copy after login

The purpose of these directories and files is:

The outermost: file: mysite/ The root directory is just a container for your project, Django does not care about its name , you can rename it to anything you like.

manage.py: A command line tool that lets you manage Django projects in various ways. You can read django-admin and manage.py for all the manage.py details.

The mysite/ directory inside contains your project, which is a pure Python package. Its name is the Python package name you use when referencing anything inside it. (e.g. mysite.urls).

mysite/__init__.py: An empty file that tells Python that this directory should be considered a Python package. If you are new to Python, read more about packages in the official documentation.

mysite/settings.py: Configuration file of the Django project. If you want to know how this file works, check out Django settings for details.

mysite/urls.py: The URL declaration of the Django project, like the "directory" of your website. Read the URL dispatcher documentation to learn more about URLs.

mysite/wsgi.py: serves as the entry point for your project to run on a WSGI-compatible web server. Read How to deploy with WSGI for more details.

[Recommended course: Django video tutorial]

The above is the detailed content of Write a simple Django application. For more information, please follow other related articles on the PHP Chinese website!

Related labels:
source:csdn.net
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Latest Articles by Author
Popular Tutorials
More>
Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template