1、首先跟之前说的admin的要求有点像,
vim urls.py
from django.contrib import admin
admin.autodiscover() 打开不解释,缩进要注意!
url(r'^admin/', include(admin.site.urls)),
vim settings.py
'django.contrib.admin', 同样打开 不解释!
2、这个时候 python manage.py syncdb
python manage.py runserver
登录127.0.0.1:8000:/admin
3、命令行 sqlite3 cs.db
.schema auth_user
CREATE TABLE "auth_user" (
"id" integer NOT NULL PRIMARY KEY,
"username" varchar(30) NOT NULL UNIQUE,
"first_name" varchar(30) NOT NULL,
"last_name" varchar(30) NOT NULL,
"email" varchar(75) NOT NULL,
"password" varchar(128) NOT NULL,
"is_staff" bool NOT NULL,
"is_active" bool NOT NULL,
"is_superuser" bool NOT NULL,
"last_login" datetime NOT NULL,
"date_joined" datetime NOT NULL
);
当你进入user里添加时 你会发现这些跟上面完全对应
所以就是图形化界面的操作载明航全部可以实现
select * from auth_user
1|root|||a@root.com|sha1$e63dd$be3308ac3ca26705fddf27884aca39609687e326|1|1|1|2016-01-15 07:44:30.748428|2016-01-15 07:44:30.748428
说明当前只有root 用户
4、python manage.py shell
from django.contrib.auth.models import User
User.objects.create_user('username'=ben)
ben=User.objects.get(username__exact=ben)
ben.save()
ben
现在在网页刷新也是可以看到的
ben.is_staff = True
ben.save()
ben 就从叉叉变对号了