Home > Article > Backend Development > Write a simple Django application
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
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!