Django 基础笔记01

  1. create project, create app
  2. edit settings file( time_zone, language, installed apps...)
# 支持中文本地化,这样设置。
LANGUAGE_CODE = 'zh-hans'
TIME_ZONE = 'Etc/GMT-8'
  1. start a mini index page

  2. create app/urls , and add to project/urls

  3. edit models(about db)

  4. migrate, makemigrations

  5. create superuser ,edit app/admin.py ,register app

  6. 一旦修改了models.py, 先是 makemigrations,然后是migrate

  7. 把下面3行写入一个文件,就可以创建数据了。

from blog.models import Blog
b = Blog(name='Beatles Blog', tagline='All the latest Beatles news.')
b.save()
  1. 更喜欢用:
p = Person.objects.create(first_name="Bruce", 
last_name="Springsteen")

7.slug - Matches any slug string consisting of ASCII letters or numbers,
任意字符,本意是金属块。

你可能感兴趣的:(Django 基础笔记01)