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


Python JSONSimpleSerializer.serialize方法代码示例

本文整理汇总了Python中common.serializers.JSONSimpleSerializer.serialize方法的典型用法代码示例。如果您正苦于以下问题:Python JSONSimpleSerializer.serialize方法的具体用法?Python JSONSimpleSerializer.serialize怎么用?Python JSONSimpleSerializer.serialize使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在common.serializers.JSONSimpleSerializer的用法示例。


在下文中一共展示了JSONSimpleSerializer.serialize方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: sale_json

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def sale_json(request):
  serializer = JSONSimpleSerializer()
  if 'sn' in request.GET:
    sale = SaleOrder.objects.filter(sn = request.GET['sn'])
  else:
    sale = SaleOrder.objects.all()
  return HttpResponse(serializer.serialize(sale, use_natural_foreign_keys=True))
开发者ID:suall936,项目名称:ozbuy,代码行数:9,代码来源:views.py

示例2: customer_delete

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def customer_delete(request):
  if request.method == 'POST':
    delete_customer = Customer.objects.get(sn=request.POST['sn'])
    delete_name = unicode(delete_customer)
    delete_customer.delete()
    serializer = JSONSimpleSerializer()
    return HttpResponse(serializer.serialize([delete_customer,]))
  else:
    return HttpResponse("Invalid request.")
开发者ID:suall936,项目名称:ozbuy,代码行数:11,代码来源:views.py

示例3: saleItem_json

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def saleItem_json(request):
  """return json of all sale_items with sn as sale.sn. For ajax"""
  if request.GET['sn']:
    try:
      p = SaleOrder.objects.get(sn=request.GET['sn'])
    except SaleOrder.DoesNotExist:
      raise Http404
    pi = p.saleitem_set.all().order_by("sn")
    serializer = JSONSimpleSerializer()
    return HttpResponse(serializer.serialize(pi, use_natural_foreign_keys=True))
  else:
    return HttpResponse("Invalid request.")
开发者ID:suall936,项目名称:ozbuy,代码行数:14,代码来源:views.py

示例4: vendor_add

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def vendor_add(request):
  if request.method == 'POST':
    form = VendorForm(request.POST)
    if form.is_valid():
      p = form.save(commit=False)
      p.sn = generate_sn(prefix = 'VDR')
      p = form.save()
      serializer = JSONSimpleSerializer()
      return HttpResponse(serializer.serialize([p,], use_natural_foreign_keys=True))
  else:
    form = VendorForm()
    return render_to_response('modal/main_form.html',{'action':'Add', 'module':module, 'form': form},context_instance=RequestContext(request))
开发者ID:suall936,项目名称:ozbuy,代码行数:14,代码来源:views.py

示例5: currencyRate_json

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def currencyRate_json(request):
  """return json of all currencyRate with sn as currency.sn. For ajax"""
  if request.GET['sn']:
    try:
      p = Currency.objects.get(sn=request.GET['sn'])
    except Currency.DoesNotExist:
      raise Http404
    pi = p.fromRates.all().order_by("sn")
    serializer = JSONSimpleSerializer()
    return HttpResponse(serializer.serialize(pi, use_natural_foreign_keys=True))
  else:
    return HttpResponse("Invalid request.")
开发者ID:suall936,项目名称:test,代码行数:14,代码来源:views.py

示例6: customer_add

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def customer_add(request):
  if request.method == 'POST':
    form = CustomerForm(request.POST)
    if form.is_valid():
      c = form.save(commit=False)
      c.sn = generate_sn(prefix = 'CTM')
      c.save()
      serializer = JSONSimpleSerializer()
      return HttpResponse(serializer.serialize([c,]))
  else:
    form = CustomerForm()
    return render_to_response('modal/main_form.html',{'action':'Add', 'module':module, 'form': form},context_instance=RequestContext(request))
开发者ID:suall936,项目名称:ozbuy,代码行数:14,代码来源:views.py

示例7: currencyRate_update

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def currencyRate_update(request):
  if request.method == 'POST':
    postdata = request.POST.copy()
    sn = postdata.pop('sn')[0]
    p = Currency.objects.get(pk=postdata['fromCurrency'][0])
    pi = CurrencyRate.objects.get(fromCurrency=p, sn=sn)
    form = CurrencyRateForm(postdata, instance=pi)
    if form.is_valid():
      pi_saved = form.save()
      serializer = JSONSimpleSerializer()
      return HttpResponse(serializer.serialize([pi_saved,], use_natural_foreign_keys=True))
  else:
    pass
开发者ID:suall936,项目名称:test,代码行数:15,代码来源:views.py

示例8: product_update

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def product_update(request):
  if request.method == 'POST':
    postdata = request.POST.copy()
    try:
      c = Product.objects.get(sn=postdata.pop('sn')[0])
    except Product.DoesNotExist:
      raise Http404
    form = ProductForm(postdata, instance=c)
    if form.is_valid():
      p = form.save()
      serializer = JSONSimpleSerializer()
      return HttpResponse(serializer.serialize([p,], use_natural_foreign_keys=True))
  else:
      return HttpResponse('Invalid request.')
开发者ID:suall936,项目名称:test,代码行数:16,代码来源:views.py

示例9: vendor_update

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def vendor_update(request):
  if request.method == 'POST':
    postdata = request.POST.copy()
    try:
      c = Vendor.objects.get(sn=postdata.pop('sn')[0])
    except Vendor.DoesNotExist:
      raise Http404(module + ' not found')
    form = VendorForm(postdata, instance=c)
    if form.is_valid():
      c_saved = form.save()
      serializer = JSONSimpleSerializer()
      return HttpResponse(serializer.serialize([c_saved,]))
  else:
    return HttpResponse('Invalid request.')
开发者ID:suall936,项目名称:ozbuy,代码行数:16,代码来源:views.py

示例10: saleItem_update

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def saleItem_update(request):
  if request.method == 'POST':
    postdata = request.POST.copy()
    p_pk = postdata.pop('order')[0]
    sn = postdata.pop('sn')[0]
    p = SaleOrder.objects.get(pk=p_pk)
    pi = SaleItem.objects.get(order=p, sn=sn)
    form = SaleItemForm(postdata, instance=pi)
    if form.is_valid():
      pi_saved = form.save()
      serializer = JSONSimpleSerializer()
      return HttpResponse(serializer.serialize([pi_saved,], use_natural_foreign_keys=True))
  else:
    pass
开发者ID:suall936,项目名称:ozbuy,代码行数:16,代码来源:views.py

示例11: currency_update

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def currency_update(request):
  if request.method == 'POST':
    postdata = request.POST.copy()
    try:
      p = Currency.objects.get(sn=postdata.pop('sn')[0])
    except Currency.DoesNotExist:
      raise Http404(module + ' not found')
    form = CurrencyForm(postdata, instance=p)
    print form.errors
    if form.is_valid():
      p_saved = form.save()
      serializer = JSONSimpleSerializer()
      return HttpResponse(serializer.serialize([p_saved,]))
  else:
    return HttpResponse('Invalid request.')
开发者ID:suall936,项目名称:test,代码行数:17,代码来源:views.py

示例12: purchase_update

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def purchase_update(request):
  if request.method == 'POST':
    postdata = request.POST.copy()
    try:
      p = PurchaseOrder.objects.get(sn=postdata.pop('sn')[0])
    except PurchaseOrder.DoesNotExist:
      raise Http404(module + ' not found')
    form = PurchaseForm(postdata, instance=p)
    print form.errors
    if form.is_valid():
      p_saved = form.save()
      serializer = JSONSimpleSerializer()
      return HttpResponse(serializer.serialize([p_saved,],use_natural_foreign_keys=True))
  else:
    return HttpResponse('Invalid request.')
开发者ID:suall936,项目名称:ozbuy,代码行数:17,代码来源:views.py

示例13: purchaseItem_add

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def purchaseItem_add(request):
  if request.method == 'POST':
    postdata = request.POST.copy()
    p_sn = postdata.pop('itemLinkSn')[0]
    sn = postdata.pop('sn')[0]
    form = Purchase_ItemForm(postdata)
    if form.is_valid():
      pi = form.save(commit=False)
      p = PurchaseOrder.objects.get(sn=p_sn)
      pi.order = p
      pi.sn = Purchase_Item.objects.filter(order = p).count() + 1
      pi.save()
      serializer = JSONSimpleSerializer()
      return HttpResponse(serializer.serialize([pi,], use_natural_foreign_keys=True))
  else:
    return HttpResponse("Invalid request.")
开发者ID:suall936,项目名称:ozbuy,代码行数:18,代码来源:views.py

示例14: currencyRate_add

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def currencyRate_add(request):
  if request.method == 'POST':
    postdata = request.POST.copy()
    # currency_pk = postdata.pop('fromCurrency')[0]
    sn = postdata.pop('sn')[0]
    form = CurrencyRateForm(postdata)
    if form.is_valid():
      pi = form.save(commit=False)
      p = Currency.objects.get(pk=postdata['fromCurrency'][0])
      # pi.sn = CurrencyRate.objects.filter(fromCurrency = p).count() + 1
      pi.sn = p.fromRates.count() + 1
      pi.save()
      serializer = JSONSimpleSerializer()
      return HttpResponse(serializer.serialize([pi,], use_natural_foreign_keys=True))
  else:
    return HttpResponse("Invalid request.")
开发者ID:suall936,项目名称:test,代码行数:18,代码来源:views.py

示例15: currencyConvertTo_json

# 需要导入模块: from common.serializers import JSONSimpleSerializer [as 别名]
# 或者: from common.serializers.JSONSimpleSerializer import serialize [as 别名]
def currencyConvertTo_json(request):
  """return json of all currencyRate with sn specified the currency converted to. For ajax"""
  if request.GET['sn']:
    try:
      p = Currency.objects.get(sn=request.GET['sn'])
      print p
    except Currency.DoesNotExist:
      raise Http404
    if p.code == 'AUD':
      fromCurrency = Currency.objects.get(code ='CNY')
    elif p.code == 'CNY':
      fromCurrency = Currency.objects.get(code ='AUD')
    pi = p.toRates.all().filter(fromCurrency = fromCurrency).order_by('-isDefault')
    serializer = JSONSimpleSerializer()
    return HttpResponse(serializer.serialize(pi, use_natural_foreign_keys=True))
  else:
    return HttpResponse("Invalid request.")
开发者ID:suall936,项目名称:test,代码行数:19,代码来源:views.py


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