标签:其他 auth field roo length 意思 style base ajax
django-admin startproject test5
cd test5
python manage.py startapp school
INSTALLED_APPS = [ ‘django.contrib.admin‘, ‘django.contrib.auth‘, ‘django.contrib.contenttypes‘, ‘django.contrib.sessions‘, ‘django.contrib.messages‘, ‘django.contrib.staticfiles‘, ‘school‘, ]
DATABASES = { ‘default‘: { ‘ENGINE‘: ‘django.db.backends.mysql‘, ‘NAME‘: ‘school‘, ‘USER‘: ‘root‘, ‘PASSWORD‘: ‘toor‘, ‘HOST‘: ‘localhost‘, ‘PORT‘: 3306, } }
TEMPLATES = [ { ‘BACKEND‘: ‘django.template.backends.django.DjangoTemplates‘, ‘DIRS‘: [os.path.join(BASE_DIR, ‘templates‘)], ‘APP_DIRS‘: True, ‘OPTIONS‘: { ‘context_processors‘: [ ‘django.template.context_processors.debug‘, ‘django.template.context_processors.request‘, ‘django.contrib.auth.context_processors.auth‘, ‘django.contrib.messages.context_processors.messages‘, ], }, }, ]
from django.contrib import admin from django.urls import path, include
app_url_patterns = (‘school.urls‘, ‘school‘)
urlpatterns = [ path(‘admin/‘, admin.site.urls), path(‘‘, include(app_url_patterns, namespace=‘school‘)), ]
from django.urls import re_path, include from . import views urlpatterns=[ re_path(r‘^$‘, views.index, name=‘index‘), ]
from django.shortcuts import render def index(request): return render(request, ‘school/index.html‘)
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>常用技术练习</title> </head> <body> <h1>常用技术练习</h1> </body> </html>
from django.db import models class AreaInfo(models.Model): """地区模型类""" name = models.CharField(max_length=50) area_parent = models.ForeignKey(‘self‘, on_delete=models.CASCADE, null=True, blank=True)
标签:其他 auth field roo length 意思 style base ajax
原文地址:https://www.cnblogs.com/Hannibal-2018/p/11105251.html