This file contains 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 requests | |
from StringIO import StringIO | |
from product.models import Product, Photo | |
from django.core.files.base import ContentFile | |
response = requests.get('http://photo-url/image.jpg') | |
file = StringIO(response.content) | |
file_content = ContentFile(file.read()) |
This file contains 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 Randomize(object): | |
def _get_multiplier(self): | |
if not hasattr(self, 'multiplier') or \ | |
self.multiplier == None: | |
self.multiplier = 2 | |
else: | |
if self.multiplier == 9: |
This file contains 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 Company(models.Model): | |
name = models.CharField(max_length=100) | |
class Product(models.Model): | |
name = models.CharField(max_length=100) | |
class Quotation(models.Model): | |
product = models.ForeignKey('app.Product', related_name=quotations) | |
company = models.ForeignKey('app.Company') | |
price = models.DecimalField(...) |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains 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 ng-app="fooBar"> | |
<head> | |
<script data-require="angular.js@*" data-semver="1.4.3" src="https://code.angularjs.org/1.4.3/angular.js"></script> | |
<link rel="stylesheet" href="style.css" /> | |
<script type="text/ng-template" id="tpl.html"> | |
<h1>{{message}}</h1> | |
</script> | |
<script src="script.js"></script> |
This file contains 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
* easy way to set style of a sheet | |
* totalization ? | |
* Use more that one "table" by sheet. | |
- Maybe use cursors. (self.cursor_row, self.cursor_line) |
This file contains 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
#coding:utf-8 | |
from south.signals import post_migrate | |
def update_permission_after_migration(app, **kwargs): | |
""" | |
your_project.__init__.py is a nice place to stay | |
Update app permission just after every migration. | |
This is based on app djando_extensions update_permissions management command. | |
""" |
This file contains 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.utils import six | |
from django.utils.encoding import force_str | |
class ReadOnlyFieldsMixin(object): | |
readonly_fields = () | |
def __init__(self, *args, **kwargs): | |
super(ReadOnlyFieldsMixin, self).__init__(*args, **kwargs) | |
self.define_readonly_fields(self.fields) |
This file contains 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 decimal import Decimal | |
>>> Decimal('2.14999').quantize(Decimal('0.00')) | |
Decimal('2.15') |
This file contains 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 'agendamento/base_comitente.html' %} | |
{% load bootstrap %} | |
{% block extra_css %} | |
<style> | |
.form-actions{ | |
padding:10px; | |
background-color:#EEE; | |
border-top:1px solid #CCC; | |
} |