After installing Django, you have installed the available management tools django-admin.py, which you can use to create projects and run django-admin.py to view the command description:
See how one of these commands are used:
Create a new project:
To view the directory structure:
Catalogue Description:
- HelloWorld: the container for the project.
- manage.py: a useful command-line tool that allows you to interact with the Django project in a variety of ways.
- helloworld/__init__.py: An empty file that tells Python that the directory is a python package.
- helloworld/settings.py: setup/configuration for this Django project.
- helloworld/urls.py: URL declaration for the Django project; A "directory" of Django-driven Web sites.
- helloworld/wsgi.py: a WSGI-compatible WEB server's portal to run your project.
Next we go into the HelloWorld directory and enter the following command to start the server:
Python manage. 0.0. 0.0:8000
0.0.0.0 allow other computers to connect to the development server, 8000 is the port number. If not stated, the port number defaults to 8000.
In the browser input your server's IP and port number, if normal startup, the output is as follows:
Create a view.py file under Path C:\Users\XCC\HelloWorld\HelloWorld, and enter the following code:
from Import HttpResponse def Hello (Request): return HttpResponse ("")
Bind the URL with the view function, replacing the code in the original urls.py with the following code:
from Import * fromimport= Patterns ("", ('^hello /$', hello),)
Entire Directory structure:
After starting the Django Development server, access in the browser:
Note: If the code changes in the project, the server will automatically monitor the code changes and reload automatically, so if you have already started the server, you do not need to restart manually.
Django Administration Tool django-admin.py creating a project