Skip to content

Instantly share code, notes, and snippets.

View rhenter's full-sized avatar

Rafael Henter rhenter

View GitHub Profile
@rhenter
rhenter / form_paginate_by.html
Created September 18, 2020 21:23
Includes de Paginação e busca para Django usando Bootstrap
{% load i18n %}
<div class="card-tools">
<form class="form-inline" action="." method="GET">
<div class="input-group input-group-sm" style="margin-left: 20px;">
<label for="id_paginate" style="margin-right: 5px;">{% trans "Show" %}</label>
<select class="form-control" name="paginate_by" id="id_paginate" onchange="this.form.submit()">
{% for pages in range_pagination %}
{% if paginate_by == pages %}
<option selected="selected">{{ pages }}</option>
@rhenter
rhenter / mixins.py
Last active September 18, 2020 21:28
Mixins de Busca e Filtros e exemplo de como fazer uma buscar e um filtro pegando da URL usando Django
import operator
from functools import reduce
from django.contrib.auth.mixins import LoginRequiredMixin
from django.db import models
from django.views.generic import ListView
from django.views.generic.base import ContextMixin
from django_stuff.utils import remove_special_characters
from quotation_project.utils import clean_url
@rhenter
rhenter / base_print.html
Last active August 8, 2020 10:48
Imprimir para PDF
{% load i18n %}
{% load l10n %}
{% load static %}
{% load app_utils %}
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
@rhenter
rhenter / models.py
Last active January 15, 2020 01:37
Cadastro do usuario com endereço separado
class User(models.Model):
email = models.EmailField()
endereco = models.ForeignKey(Endereco)
class State(models.Model):
name = models.CharField()
class City(models.Model):
name = models.CharField()
@rhenter
rhenter / cep.py
Last active July 18, 2019 08:16
Pesquisa de CEP
#!/usr/bin/env python
# encoding: utf-8
import re
import sys
import requests
API_CEP = 'http://api.postmon.com.br/v1/cep/{}'
@rhenter
rhenter / forms.py
Last active July 3, 2019 22:34
Criação de Modelo de Usuário Customizado
from django import forms
from django.contrib.auth import get_user_model, password_validation
User = get_user_model()
class RegisterForm(forms.ModelForm):
password2 = forms.CharField(
label="Confirmacao",
#!/bin/bash
set -e
apps=( "olist-orders-api" "olist-freights-api" "olist-correios-api" )
order_exclude_tables=( "olist_orders_orderhistory" "olist_orders_orderhistory" "seller_orders_sellerorderhistory" "seller_orders_sellerorderitemhistory" )
correios_exclude_tables=( )
freights_exclude_tables=( )
get_exclude_params() {
@rhenter
rhenter / forms.py
Last active November 6, 2017 15:51
Django Custom User
from django import forms
from django.contrib.auth.forms import UserCreationForm
class FormSignUp(UserCreationForm):
email = forms.CharField(max_length=254, required=True, widget=forms.EmailInput())
class Meta:
model = User
fields = [
import sys
sys.path.append('CAMINHO_DO_PROJETO')
from NOME_DO_PROJETO import settings
from django.core.management import setup_environ
setup_environ(settings)
#!/usr/bin/env python
import json
import boto3
def get_content_file(path):
with open(path, 'rb') as content_file:
data = content_file.read()
return data