本文整理汇总了Python中models.Product.name方法的典型用法代码示例。如果您正苦于以下问题:Python Product.name方法的具体用法?Python Product.name怎么用?Python Product.name使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Product
的用法示例。
在下文中一共展示了Product.name方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: create
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import name [as 别名]
def create(request, keyname):
"Backdoor to create a new entity"
u = auth.get_current_user(request)
if u.is_admin:
p = Product(key_name=keyname)
p.name = "New Product"
p.description = "The description"
p.put()
return HttpResponseRedirect(reverse('store-edit', args=(p.key(),)))
return HttpResponseRedirect(reverse('store-index'))
示例2: products
# 需要导入模块: from models import Product [as 别名]
# 或者: from models.Product import name [as 别名]
def products(request):
action = request.GET.get('action')
if action == 'criar':
inputNome = request.GET.get('inputNome')
if inputNome is not None:
inputCapacidade = request.GET.get('inputCapacidade')
inputTipo = request.GET.get('inputTipo')
newProduct = Product()
newProduct.name = inputNome
newProduct.capacity = inputCapacidade
newProduct.type = inputTipo[0]
newProduct.creation_date = datetime.datetime.now()
newProduct.save()
ProductsResult = Product.objects.all()
page = request.GET.get('pagina')
paginator = Paginator(ProductsResult, 20) #Show 20 per page
try:
ProductsResult = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
ProductsResult = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
ProductsResult = paginator.page(paginator.num_pages)
# FeaturesResult = Features.objects.all()
return render(request, 'SisLocApp/products.html', {'ProductsResult': ProductsResult,
'action': 'listar',
'status': 'created'})
return render(request, 'SisLocApp/products.html', {'action': 'criar'})
elif action == 'excluir':
inputExcluir = request.GET.get('inputExcluir')
ProductDeleted = Product.objects.filter(id=inputExcluir)
ProductDeleted.delete()
ProductsResult = Product.objects.all()
page = request.GET.get('pagina')
paginator = Paginator(ProductsResult, 20) #Show 20 per page
try:
ProductsResult = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
ProductsResult = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
ProductsResult = paginator.page(paginator.num_pages)
# FeaturesResult = Features.objects.all()
return render(request, 'SisLocApp/products.html', {'ProductsResult': ProductsResult,
'action': 'listar',
'status': 'deleted'})
elif action == 'alterar':
inputAlterar = request.GET.get('inputAlterar')
ProductsResult = Product.objects.get(id=inputAlterar)
inputNome = request.GET.get('inputNome')
if inputNome is None:
return render(request, 'SisLocApp/products.html', {'ProductsResult': ProductsResult,
'action': 'alterar'})
inputCapacidade = request.GET.get('inputCapacidade')
inputTipo = request.GET.get('inputTipo')
ProductsResult.name = inputNome
ProductsResult.capacity = inputCapacidade
ProductsResult.type = inputTipo[0]
ProductsResult.save()
ProductsResult = Product.objects.all()
page = request.GET.get('pagina')
paginator = Paginator(ProductsResult, 20) #Show 20 per page
try:
ProductsResult = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
ProductsResult = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
ProductsResult = paginator.page(paginator.num_pages)
# FeaturesResult = Features.objects.all()
return render(request, 'SisLocApp/products.html', {'ProductsResult': ProductsResult,
'action': 'listar',
'status': 'updated'})
else:
ProductsResult = Product.objects.all()
page = request.GET.get('pagina')
paginator = Paginator(ProductsResult, 20) #Show 20 per page
try:
ProductsResult = paginator.page(page)
except PageNotAnInteger:
# If page is not an integer, deliver first page.
ProductsResult = paginator.page(1)
except EmptyPage:
# If page is out of range (e.g. 9999), deliver last page of results.
ProductsResult = paginator.page(paginator.num_pages)
# FeaturesResult = Features.objects.all()
return render(request, 'SisLocApp/products.html', {'ProductsResult': ProductsResult,
'action': 'listar'})