Skip to content

Instantly share code, notes, and snippets.

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
</head>
<body>
<div ng-app="CalculatorApp" ng-controller="CalculatorController">
<!-- se inicializa el ng-model con gn-init="nombreModel=value" -->
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.8/angular.min.js"></script>
</head>
<body>
<div ng-app="CalculatorApp" ng-controller="CalculatorController">
<!-- se inicializa el ng-model con gn-init="nombreModel=value" -->
import json
from rojoverdeajo.espaciofisico.models import zona
#obtener todas las zonas
zonas = Zona.objects.all()
#construir una lista de diccionarios que representen a las zonas
lista = [{'pk': zona.pk, 'zona': zona.zona} for zona in zonas]
#convertir eso en un json
mport datetime
from django.db import models
class Category(models.Model):
"""
Top level category model
"""
title = models.CharField(max_length=64, unique=True)
def __str__(self):
@dafma
dafma / vbf-crud.py
Last active January 21, 2016 19:25
####views
from django.shortcuts import render, redirect, get_object_or_404
from django.forms import ModelForm
from books_fbv.models import Book
class BookForm(ModelForm):
class Meta:
model = Book
fields = ['name', 'pages']
<table class="table">
<thead>
<tr>
<th>Id</th>
<th>Nombre</th>
<th>Cantidad</th>
<th>Precio unidad</th>
<th>Total producto</th>
<th>Eliminar</th>
</tr>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Document</title>
<style>
.video-container {
position: relative;
padding-bottom: 56.25%;
padding-top: 30px; height: 0; overflow: hidden;
from django.db.models import Sum
total_price = Bill.objects.all().aggregate(Sum('price'))
#obtener el lapso de dias
from datetime import datetime, timedelta
n = 2
dias_pasados = datetime.now() - timedelta(days=n)
print datetime.now()
print dias_pasados
from django.template import Library
register = Library()
@register.filter
def get_range( value ):
"""
Filter - returns a list containing range made from given value
Usage (in template):