#### Python uses Django to create its own blog (above) mainly recorded in the project creation, project file structure, background super user creation, add data to the database, etc. This blog is mainly loaded HTML static files and display between the loading logic, etc. ##### website display and logic processing

View.py is the main code editing area in the logical code module project that executes the responseCopy the code

Templates are mostly static files for HTML and CSS layouts

Jinja2 create a directory named templates in the APP directory. Create a directory. Create an HTML file in that directory. The render function supports dict arguments that are passed in the background to the template. The key values are parameter names that are used directly in the template using {{parameter name}}Copy the code

urls.py

Url configuration files django projects require us to configure their addresses to link toCopy the code

For more complex content we can create our own urls.py file for each APP, with the second parameter of the function in the root urls.py changed to

 url(r'^article/', include('article.urls')),
Copy the code

This is done to facilitate maintenance of the project’s contents in article/urls.py if the project is large

from . import views
urlpatterns = [
    url(r'^index/$', views.index),   ## add constraint index followed by /
]
Copy the code

Matters needing attention:

  • Note the $and/symbols at the end of the url’s regular expression
  • Note the path Settings in the root urls.py

##### displays Hello World we first display a Hello World so all we need to do is associate urls.py with views.py in urls.py

urlpatterns = [
    url(r'^admin/', include(admin.site.urls)),
    url(r'^ $'.'article.views.home'),]Copy the code

Load the home function in views.py

def home(request):
    return HttpResponse("Hello World!")
Copy the code

Then run the backend server or use PyCharm to start the project

python manage.py runserver
Copy the code

The following information is displayed:

Django build easy blog tutorials
Pure

Python to Create your own Blog with Django (3 Pure Framework Introduction)
DjangoIntroduction –DjangoTutorial –Striving to improve school
For class network