Skip to content

Instantly share code, notes, and snippets.

View samirbr's full-sized avatar

Sam Aouar samirbr

View GitHub Profile
# coding=utf-8
from django.conf.urls import patterns, url, include
from rest_framework import routers
from .views import (ClientPlanViewSet, PlanViewSet,
ClientPlanReportViewSet, ReportUsage)
router = routers.DefaultRouter()
router.register(r'billing/manage', ClientPlanViewSet,
base_name='billing_manage')
from django.db import models
import json
class JSONField(models.TextField):
def __init__(self, verbose_name=None, name=None, default=None, **kwargs):
models.TextField.__init__(self, verbose_name, name, **kwargs)
def to_python(self, value):
if isinstance(value, six.string_types) or value is None:
return value
value = { 'a':
{
'c': 1,
'd': [
{ 'a': 1 }
]
}
}
var $input = $('#id_cpf');
$input[0].sent = false;
$input.keyup(function () {
var value = $(this).val();
if (value.length === 11 && !this.sent){
this.sent = true;
$.ajax({ /* ajax goes here */ });
@samirbr
samirbr / dados.py
Last active February 1, 2016 20:35
if isinstance(dados, dict):
Passagens126.objects.create(**to_kwargs(dados))
else:
for item in dados:
print(item)
Passagens126.objects.create(**to_kwargs(item))
parent = get_object_or_404(queryset, id=int(parent_id), user=rootuser)
data = Question.objects.filter(parent=parent, deleted=False)
serializer = QuestionListSerializer(data)
serializer.data
erro:
IndexError Traceback (most recent call last)