This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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" --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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" --> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
####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'] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.db.models import Sum | |
total_price = Bill.objects.all().aggregate(Sum('price')) | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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): |
OlderNewer