當前位置: 首頁>>代碼示例>>Python>>正文


Python serializers.JSONSimpleSerializer類代碼示例

本文整理匯總了Python中common.serializers.JSONSimpleSerializer的典型用法代碼示例。如果您正苦於以下問題:Python JSONSimpleSerializer類的具體用法?Python JSONSimpleSerializer怎麽用?Python JSONSimpleSerializer使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。


在下文中一共展示了JSONSimpleSerializer類的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: sale_json

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,代碼行數:7,代碼來源:views.py

示例2: customer_delete

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,代碼行數:9,代碼來源:views.py

示例3: saleItem_json

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,代碼行數:12,代碼來源:views.py

示例4: vendor_add

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,代碼行數:12,代碼來源:views.py

示例5: currencyRate_json

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,代碼行數:12,代碼來源:views.py

示例6: customer_add

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,代碼行數:12,代碼來源:views.py

示例7: currencyRate_update

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,代碼行數:13,代碼來源:views.py

示例8: product_update

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,代碼行數:14,代碼來源:views.py

示例9: vendor_update

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,代碼行數:14,代碼來源:views.py

示例10: saleItem_update

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,代碼行數:14,代碼來源:views.py

示例11: currency_update

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,代碼行數:15,代碼來源:views.py

示例12: purchase_update

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,代碼行數:15,代碼來源:views.py

示例13: purchaseItem_add

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,代碼行數:16,代碼來源:views.py

示例14: currencyRate_add

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,代碼行數:16,代碼來源:views.py

示例15: currencyConvertTo_json

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,代碼行數:17,代碼來源:views.py


注:本文中的common.serializers.JSONSimpleSerializer類示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。