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
#!/bin/bash | |
# This script will compile the translation messages of all translatable django applications | |
# Author: AxiaCore S.A.S. http://axiacore.com | |
langs="es" | |
a=`ls -l | grep ^d | awk '{print $9}'`; | |
curdir=`pwd` | |
for i in $a | |
do |
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
CartSale.objects.annotate(Count('products'),Sum('products__quantity')) |
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
#Para contar la cantidad de ventas que se han efectuado: | |
Cartsale.objects.count() | |
#Para contar el precio promedio del valor de los artículos vendidos: | |
CartProduct.objects.aggregate(Avg('price')) | |
#Para obtener la cantidad de productos que se han vendido: | |
CartProduct.objects.aggregate(Sum('quantity')) | |
#Para obtener la cantidad de compras registradas a nombre de un mismo correo: |
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
class CartSale(models.Model): | |
first_name = models.CharField( | |
max_length=100, | |
) | |
last_name = models.CharField( | |
max_length=100, | |
) | |
date_sale = models.DateTimeField( | |
auto_now_add=True, | |
) |
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.contrib import admin | |
import autocomplete_light | |
from models import Address | |
class AddressAdmin(admin.ModelAdmin): | |
form = autocomplete_light.modelform_factory(Address) | |
admin.site.register(Address, AddressAdmin) |
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 autocomplete_light | |
from cities_light.models import City | |
autocomplete_light.register(City, search_fields=('search_names',), | |
autocomplete_js_attributes={'placeholder': 'city name ..'}) |
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
{% extends "admin/base.html" %} | |
{% block extrahead %} | |
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.7.2/jquery.min.js" type="text/javascript"></script> | |
{% include 'autocomplete_light/static.html' %} | |
{% endblock %} |
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 autocomplete_light | |
autocomplete_light.autodiscover() |
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
url(r'autocomplete/', include('autocomplete_light.urls')), |
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
pip install django-autocomplete-light |