创建users:
Django 从开始就带有一个用户认证系统,它处理用户账号,组,权限以及基于cookie的永不会话
Python 2.7.3 (default, Mar 30 2017, 20:15:12)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os,django
>>> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
'mysite.settings'
>>> django.setup()
aaaaaaaaaaaaaaaa
>>> from django.contrib.auth.models import User
>>>
node2:/root#cd /django
You have new mail in /var/spool/mail/root
node2:/django#cd mysite
node2:/django/mysite#python
Python 2.7.3 (default, Mar 30 2017, 20:15:12)
[GCC 4.4.7 20120313 (Red Hat 4.4.7-17)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import os,django
>>> os.environ.setdefault("DJANGO_SETTINGS_MODULE", "mysite.settings")
'mysite.settings'
>>> django.setup()
aaaaaaaaaaaaaaaa
>>> from django.contrib.auth.models import User
>>>
>>> from django.contrib.auth.models import User
>>> allnavi = User.objects.all()
>>> allnavi
<QuerySet [<User: john>, <User: xxxx>, <User: scan>, <User: 015208>, <User: admin>]>
>>>
mysql> select username from auth_user;
+----------+
| username |
+----------+
| 015208 |
| admin |
| john |
| scan |
| xxxx |
+----------+
5 rows in set (0.00 sec)
user = User.objects.create_user('kebo', 'kobe@thebeatles.com', '9999')
>>> user = User.objects.create_user('kebo', 'kobe@thebeatles.com', '9999')
>>> user.last_name
u''
>>> user.username
u'kebo'
>>> user.email
u'kobe@thebeatles.com'