Exemplo n.º 1
0
def get_distric(request):
    name = request.GET.get('name', '')
    dists = District.objects.filter(canton__pk=request.GET.get('canton', "0"))
    initial = request.GET.get("initial", "0")
    attrs = str_2_obj(request.GET.get('attrs', ''))
    try:
        initial = int(initial)
    except:
        initial = 0
    return JsonResponse({'id':'div_district_' + name,
                         'content': render_option(dists, name,
                                                  label=_("District"),
                                                  function_load=" ",
                                                  prefix="",
                                                  initial=initial,
                                                  attrs=attrs)})
Exemplo n.º 2
0
def get_canton(request):
    name = request.GET.get('name', '')
    canton = Canton.objects.filter(province__pk=request.GET.get('province', "0"))
    initial = request.GET.get("initial", "0")
    attrs = str_2_obj(request.GET.get('attrs', ''))

    try:
        initial = int(initial)
    except:
        initial = 0
    return JsonResponse({'id':'div_canton_' + name,
                         'content': render_option(canton, name,
                                                  label=_("Canton"),
                                                  function_load="load_district(this, undefined)",
                                                  prefix="canton_",
                                                  initial=initial,
                                                  attrs=attrs)})