1. Create a django project
Use django-admin.py startproject MyDjangoSite. Refer here
2. Create a view
from django. http import HttpResponsedef hello(request): Return HttpResponse("My first simple python django project.")
3. Modify urls.py
We add a line to urlpatterns: (r'^hello/$', hello), this line is called URLpattern, which is a Python tuple. The first element in the tuple is the pattern matching string (regular expression); the second element is the view function that will be used by that pattern.
Regular expression string starting with letter "r". It tells Python that this is a raw string and does not need to deal with the backslashes (escape characters) inside. It is generally a good habit to add "r" before using a regular expression!
4. Run python manage.py runserver
How to start the development server can be seen here
http://127.0.0.1:8000/hello
For more articles related to using python Django to make web pages, please pay attention to the PHP Chinese website!