当前位置: 首页>>代码示例>>Python>>正文


Python Product.name方法代码示例

本文整理汇总了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'))
开发者ID:nicocrm,项目名称:Sailfish.Web,代码行数:12,代码来源:views.py

示例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'})
开发者ID:AsaK,项目名称:SisLoc,代码行数:96,代码来源:views.py


注:本文中的models.Product.name方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。