• 使用使用Django认证系统之创建users


    创建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'
    
  • 相关阅读:
    136-如何访问redis数据库
    135-如何实现result风格
    134-SpringMVC中的值,会有一个默认值
    133-this知识点
    132-SpringBoot中的请求方法
    034-405是什么错误?
    131-逆向工程配置文件
    SQL---实验一
    《将博客搬至CSDN》
    正则表达式1---QQ号合法性判断
  • 原文地址:https://www.cnblogs.com/hzcya1995/p/13348991.html
Copyright © 2020-2023  润新知