# Criando o objeto
obj = Expense.objects.create(**data)
doc = obj.document # Pega o documento
file_url = doc.url # Pega a url
file_out_pdf = '/tmp/%s' % doc.name
file_out_jpg = '/tmp/%s.jpg' % doc.name[:-4] # remove a extensão .pdf
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 unittest | |
def rank1(ranks): | |
# by @dunossauro | |
return max([(index, value) for index, value in ranks if value], key=lambda x: x[1].split('/')[1]) | |
def rank2(ranks): | |
# by @cassiobotaro |
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
def add_q_object(self, keyword, q_object, query_parm): | |
for key in keyword: | |
kwargs = {query_parm: key.strip()} | |
q_object.add(Q(**kwargs), q_object.OR) | |
def filter_applicants(self, _queryset=None): | |
my_applicants = _queryset |
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
.break { | |
page-break-before: always !important; | |
} |
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> | |
<!-- https://getbootstrap.com/docs/4.0/examples/ --> | |
<!-- Required meta tags --> | |
<meta charset="utf-8"> | |
<meta name="viewport" content="width=device-width, initial-scale=1, shrink-to-fit=no"> | |
<meta name="description" content=""> |
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
#!/usr/bin/env python | |
""" | |
Django SECRET_KEY generator. | |
""" | |
from django.utils.crypto import get_random_string | |
chars = 'abcdefghijklmnopqrstuvwxyz0123456789!@#$%^&*(-_=+)' |
Instale o django-debug-toolbar
... lembre-se de configurar o MIDDLEWARE
MIDDLEWARE = [
# ...
'debug_toolbar.middleware.DebugToolbarMiddleware',
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 messages | |
from django.contrib.auth.models import User | |
from django.db.models import Q | |
from django.shortcuts import render, redirect | |
from django.urls import reverse, reverse_lazy | |
from django.utils.encoding import force_bytes | |
from django.utils.http import urlsafe_base64_decode, urlsafe_base64_encode | |
from django.views import View | |
from django.views.generic import CreateView, ListView, UpdateView, DetailView | |
from .forms import UserForm |
Esta palestra foi apresentada no Grupy-ABC em 15 de Dezembro de 2018.
Este projeto é baseado no projeto orçamentos, feito em Django.
Tem um video no YouTube que fala um pouco sobre este projeto e a atualização de versão do Django.