本文整理汇总了Python中account.models.User.last_name方法的典型用法代码示例。如果您正苦于以下问题:Python User.last_name方法的具体用法?Python User.last_name怎么用?Python User.last_name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类account.models.User
的用法示例。
在下文中一共展示了User.last_name方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import last_name [as 别名]
def create(request):
form = CreateForm()
if request.method == 'POST':
form = CreateForm(request.POST)
if form.is_valid():
u = User()
u.username = form.cleaned_data.get('username')
u.first_name = form.cleaned_data.get('first_name')
u.last_name = form.cleaned_data.get('last_name')
u.address1 = form.cleaned_data.get('address1')
u.address2 = form.cleaned_data.get('address2')
u.birth = form.cleaned_data.get('birth')
u.set_password(form.cleaned_data.get('password'))
u.save()
u.groups.clear()
u.user_permissions.clear()
# print('Group name:', form.cleaned_data['groups'])
for group in form.cleaned_data['groups']:
print(group) # For debugging
u.groups.add(group)
for permission in form.cleaned_data['permissions']:
print(permission) # For debugging
u.user_permissions.add(permission)
u.save()
return HttpResponseRedirect('/manager/users/')
template_vars = {
'form':form,
}
return dmp_render_to_response(request, 'users.create.html', template_vars)
示例2: process_request
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import last_name [as 别名]
def process_request(request):
#process the form
form = SignupForm()
if request.method == 'POST': # just submitted the form
form = SignupForm(request.POST)
if form.is_valid():
u = User()
u.username = form.cleaned_data.get('username')
u.first_name = form.cleaned_data.get('first_name')
u.last_name = form.cleaned_data.get('last_name')
u.address1 = form.cleaned_data.get('address1')
u.address2 = form.cleaned_data.get('address2')
u.set_password(form.cleaned_data.get('password'))
u.save()
# authenticate(username=form.cleaned_data.get('username'),password=form.cleaned_data.get('password'))
# login(request, form.user)
# create a user object
# fill the user object with the data from the form
return HttpResponseRedirect('/homepage/index/')
template_vars = {
'form': form,
}
return dmp_render_to_response(request, 'signup.html', template_vars)
示例3: process_request
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import last_name [as 别名]
def process_request(request):
print('>>>>>>>>>>>>>>>>>>>>> THIS IS SIGNUP.PY')
clientemail = request.POST.get('first_name')
clientmessage = request.POST.get('last_name')
print('>>>>>>>>>> fname was', clientemail)
print('>>>>>>>>>> lname was', clientmessage)
# process the form (ie validation)
form = SignupForm()
if request.method == 'POST': # just submitted the form
form = SignupForm(request.POST)
if form.is_valid():
print('>>>>>>>>>>>>>>>>>> THE FORM IS VALID?')
u = User()
u.username = form.cleaned_data.get('username')
u.first_name = form.cleaned_data.get('first_name')
u.last_name = form.cleaned_data.get('last_name')
u.email = form.cleaned_data.get('email')
u.set_password(form.cleaned_data.get('password'))
u.address1 = form.cleaned_data.get('address')
u.address2 = form.cleaned_data.get('address2')
u.save()
return HttpResponseRedirect('/homepage/index/')
template_vars = {
'form': form,
}
return dmp_render_to_response(request, 'signup.html', template_vars)
示例4: new
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import last_name [as 别名]
def new(request):
form = CreateUserForm()
if request.method == "POST":
form = CreateUserForm(request.POST)
if form.is_valid():
user = User()
user.username = form.cleaned_data.get('username')
user.set_password(form.cleaned_data.get('password'))
user.first_name = form.cleaned_data.get('first_name')
user.last_name = form.cleaned_data.get('last_name')
user.address1 = form.cleaned_data.get('address1')
user.address2 = form.cleaned_data.get('address2')
user.birth = form.cleaned_data.get('birth')
user.phone_number = form.cleaned_data.get('phone_number')
user.save()
return HttpResponseRedirect('/manager/users')
template_vars = {
'form': form,
}
return dmp_render_to_response(request, 'users.new.html', template_vars)
示例5: process_request
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import last_name [as 别名]
def process_request(request):
# if already logged in.
if request.user.is_authenticated():
return HttpResponseRedirect('/account/manage/')
# Process the form
form = SignupForm()
if request.method == 'POST': # Just submitted the form
form = SignupForm(request.POST)
if form.is_valid():
# create a user object
u = User()
# fill the user object with the data from the form
u.username = form.cleaned_data.get('username')
u.first_name = form.cleaned_data.get('first_name')
u.last_name = form.cleaned_data.get('last_name')
u.address1 = form.cleaned_data.get('address1')
u.address2 = form.cleaned_data.get('address2')
u.set_password(form.cleaned_data.get('password'))
u.birth = form.cleaned_data.get('birth')
u.phone_number = form.cleaned_data.get('phone_number')
u.save()
u2 = authenticate(username=form.cleaned_data.get('username'), password=form.cleaned_data.get('password'))
login(request, u2)
return HttpResponseRedirect('/homepage/index/')
template_vars = {
'SignupForm': form
}
return dmp_render_to_response(request, 'signup.html', template_vars)
示例6: process_request
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import last_name [as 别名]
def process_request(request):
form = CreateAccountForm()
if request.method == "POST":
form = CreateAccountForm(request.POST)
if form.is_valid():
# create the user here
u = User()
u.username = form.cleaned_data.get("username")
u.first_name = form.cleaned_data.get("first_name")
u.last_name = form.cleaned_data.get("last_name")
u.BirthDate = form.cleaned_data.get("BirthDate")
u.Phone = form.cleaned_data.get("Phone")
u.set_password(form.cleaned_data.get("password"))
u.save()
return HttpResponse(
"""
<script>
window.location.href = '/homepage/index/';
</script>
"""
)
template_vars = {"form": form}
return dmp_render_to_response(request, "createaccount.html", template_vars)
示例7: process_request
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import last_name [as 别名]
def process_request(request):
#process the form
form = CreateUserForm()
if request.method == 'POST': # just submitted the form
form = CreateUserForm(request.POST)
if form.is_valid():
u = User()
u.username = form.cleaned_data.get('username')
u.first_name = form.cleaned_data.get('first_name')
u.last_name = form.cleaned_data.get('last_name')
u.address1 = form.cleaned_data.get('address1')
u.address2 = form.cleaned_data.get('address2')
u.set_password(form.cleaned_data.get('password'))
u.email = form.cleaned_data.get('email')
u.birth = form.cleaned_data.get('birthdate')
u.phone_number = form.cleaned_data.get('phone_number')
perms = form.cleaned_data.get('user_permissions')
groups = form.cleaned_data.get('groups')
u.save()
u.user_permissions.clear()
for x in perms:
u.user_permissions.add(x)
print(x)
u.groups.clear()
for x in groups:
u.groups.add(x)
print(x)
u.save()
#u2 = UserUserGroups()
#u2.user_id = u.id
#u2.permission_id = form.cleaned_data.get('user_permissions')
#u2.group = form.cleaned_data.get('groups')
#u.save()
#u2.save()
# authenticate(username=form.cleaned_data.get('username'),password=form.cleaned_data.get('password'))
# login(request, form.user)
# create a user object
# fill the user object with the data from the form
return HttpResponseRedirect('/manager/users/')
template_vars = {
'form': form,
}
return dmp_render_to_response(request, 'userscreate.html', template_vars)
示例8: process_request
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import last_name [as 别名]
def process_request(request):
form = SignupForm()
if request.method == 'POST':
form = SignupForm(request.POST)
if form.is_valid():
u = User()
u.username = form.cleaned_data.get('username')
u.first_name = form.cleaned_data.get('first_name')
u.last_name = form.cleaned_data.get('last_name')
u.address1 = form.cleaned_data.get('address1')
u.address2 = form.cleaned_data.get('address2')
u.set_password(form.cleaned_data.get('password'))
u.save()
return HttpResponseRedirect('/homepage/index/')
#Show HTML
template_vars = {
'form':form,
}
return dmp_render_to_response(request, 'signup.html', template_vars)
示例9: print
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import last_name [as 别名]
print('\nCreating Users...')
# This list is for choosing random users for other model associations
users = []
# 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
示例10: create_order
# 需要导入模块: from account.models import User [as 别名]
# 或者: from account.models.User import last_name [as 别名]
def create_order(request):
args = {
'form': OrderForm(),
'delivery_mass': DeliveryType.objects.all(),
'user': request.user,
'user_active': request.user.is_authenticated(),
'cart_sum': get_sum(request),
}
args.update(csrf(request))
is_valid = True
if request.user.is_authenticated():
ord = Order()
ord.first_name = request.user.first_name
ord.last_name = request.user.last_name
ord.email = request.user.email
ord.phone = request.user.phone
ord.city = request.user.city
ord.address = request.user.address
args['form'] = OrderForm(instance=ord)
if request.POST:
if request.POST.get('first_name', "") == "":
args['user_inform_error'] = True
args['first_name_error'] = "error_field"
is_valid = False
if request.POST.get('last_name', "") == "":
args['user_inform_error'] = True
args['last_name_error'] = "error_field"
is_valid = False
if request.POST.get('email', "") == "":
args['user_inform_error'] = True
args['email_error'] = "error_field"
is_valid = False
if request.POST.get('phone', "") == "":
args['user_inform_error'] = True
args['phone_error'] = "error_field"
is_valid = False
if request.POST.get('city', "") == "":
args['address_inform_error'] = True
args['city_error'] = "error_field"
is_valid = False
if request.POST.get('address', "") == "":
args['address_inform_error'] = True
args['address_error'] = "error_field"
is_valid = False
if request.POST.get('delivery', "") == "":
args['delivery_error'] = "выберите тип доставки"
args['delivery_error'] = "error_field"
is_valid = False
if 'register' in request.POST:
try:
email = request.POST.get('email', "")
User.objects.get(email=email)
args['register_error'] = "Пользователь с таким email уже разегистрирован"
is_valid = False
except User.DoesNotExist:
pass
form = OrderForm(request.POST)
if is_valid and form.is_valid():
order = form.save(commit=False)
delivery = DeliveryType.objects.get(id=request.POST['delivery'])
order.delivery = delivery.title
order.delivery_price = delivery.price
order.status = 0
print(get_sum(request))
order.sum = get_sum(request)
if request.user.is_authenticated():
order.user = request.user
order.save()
cart = get_cart(request)
if cart:
for pr in CartProduct.objects.filter(cart=cart):
if pr.product.sale_status:
pr.price_order = pr.product.price_sale
else:
pr.price_order = pr.product.price
pr.save()
order.products.add(pr)
else:
args['cart_error'] = "в вашей корзине ничего нет"
order.save()
if 'register' in request.POST:
new_user = User()
new_user.first_name = request.POST.get('first_name', "")
new_user.last_name = request.POST.get('last_name', "")
new_user.email = request.POST.get('email', "")
new_user.phone = request.POST.get('phone', "")
new_user.city = request.POST.get('city', "")
new_user.address = request.POST.get('address', "")
new_user.username = translit(new_user.first_name) + "_" + random_str(6)
password = random_str(7)
new_user.set_password(password)
new_user.save()
# отправка уведомления
#.........这里部分代码省略.........