本文整理汇总了Python中account.models.User.is_superuser方法的典型用法代码示例。如果您正苦于以下问题:Python User.is_superuser方法的具体用法?Python User.is_superuser怎么用?Python User.is_superuser使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类account.models.User
的用法示例。
在下文中一共展示了User.is_superuser方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create_users
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import is_superuser [as 别名]
def create_users():
User.objects.exclude(pk=1).delete()
for pk, fields in users.iteritems():
if pk != 1:
if fields['email'] != '':
existing = User.objects.filter(email = fields['email'])
if existing.count() > 0:
ou = existing[0]
if ou.is_active == False and fields['is_active'] == True:
replace_users[ou.pk] = pk
for k,v in replace_users.iteritems():
if v == ou.pk:
replace_users[k] = pk
ou.delete()
elif ou.is_active == True and fields['is_active'] == False:
replace_users[pk] = ou.pk
for k,v in replace_users.iteritems():
if v == pk:
replace_users[k] = ou.pk
continue
else:
replace_users[ou.pk] = pk
for k,v in replace_users.iteritems():
if v == ou.pk:
replace_users[k] = pk
ou.delete()
#print "email:", fields['email']
nu = User(pk=pk)
nu.username = fields['username']
if fields['email']:
nu.email = fields['email']
nu.status = 1
nu.password = fields['password']
nu.full_name = fields['profile']['full_name']
nu.message = fields['profile']['message']
nu.is_active = fields['is_active']
nu.is_staff = fields['is_staff']
nu.is_superuser = fields['is_superuser']
nu.comment_count = fields['profile']['comment_count']
nu.dateo_count = fields['profile']['item_count']
nu.vote_count = fields['profile']['vote_count']
nu.client_domain = datea
nu.save()
joined = date_parser(fields['date_joined'])
lastlog = date_parser(fields['last_login'])
User.objects.filter(pk=nu.pk).update(date_joined=joined, created=joined, last_login=lastlog)
for pk, fields in usersSocial.iteritems():
if fields['user'] != 1:
nusoc = UserSocialAuth(pk=pk)
nusoc.provider = fields['provider']
nusoc.uid = fields['uid']
nusoc.user_id = get_user(int(fields['user']))
nusoc.extra_data = fields['extra_data']
nusoc.save()
示例2: User
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import is_superuser [as 别名]
# Delete existing user objects
User.objects.all().delete()
# Create my superuser
u = User()
u.username = 'asmockler'
u.email = '[email protected]'
u.set_password('qwer1234')
u.first_name = 'Andy'
u.last_name = 'Mockler'
u.address1 = '850 N University Ave'
u.address2 = '303'
u.birth = datetime.datetime.now()
u.phone_number = '(801) 388-8448'
u.is_staff = True
u.is_superuser = True
u.save()
for group in Group.objects.all():
u.groups.add(group)
# Create generic users
for i in range(1, 10):
u = User()
u.username = 'user%i' % i
u.email = 'testuser%[email protected]' % i
u.first_name = 'First%i' % i
u.last_name = 'Last%i' % i
u.set_password('pass%i' % i)
u.address1 = '%i University Ave' % i
u.address2 = '00%i' % i
u.birth = datetime.datetime.now()