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
# YOU MAY WANT TO CHECK THIS OUT: https://github.com/douglasmiranda/ddpt/blob/master/{{cookiecutter.django_project_name}}/{{cookiecutter.django_project_name}}/config/local.py | |
# If you don't do this you will have to add the host IP in INTERNAL_IPS = ('127.0.0.1',) | |
# And it will change, then you will have to change INTERNAL_IPS again. | |
def show_toolbar(request): | |
if request.is_ajax(): | |
return False | |
return True |
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 lang="en"> | |
<head> | |
<meta charset="UTF-8"> | |
<title>Demo</title> | |
<script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/2.1.0/jquery.min.js"></script> | |
{{ form.media }} | |
</head> | |
<body> | |
<form action="" method="post"> |
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
INSTALL JAVA | |
sudo add-apt-repository ppa:webupd8team/java | |
sudo apt-get update | |
sudo apt-get install oracle-java8-installer | |
-- | |
# ubuntu 64bits issue | |
sudo apt-get install lib32z1 lib32ncurses5 lib32bz2-1.0 lib32stdc++6 |
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
http://www.ubuntubrsc.com/13-principais-comandos-do-ubuntu.html | |
Atualizar a lista de pacotes: sudo apt-get update | |
Efetua a atualização: sudo apt-get upgrade | |
Instalar pacotes: sudo apt-get install nome do pacote | |
Procurar pacotes: apt-cache search palavras chave | |
Procurar por dependências inválidas: sudo apt-get check | |
Corrigir problemas de dependências, concluir instalação de pacotes pendentes e outros erros: sudo apt-get -f install | |
Se o comando sudo apt-get -f install não resolver use: sudo dpkg -i –force-all para forçar a instalação ou sudo dpkg -r nome do pacote para desistir da instalação |
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
sudo apt-get build-dep python-sympy python-scipy python-matplotlib python-pandas python-nose |
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
$ python manage.py shell | |
>>> from south.models import MigrationHistory | |
>>> m = MigrationHistory.objects.get(migration='<migration_name>') | |
>>> m.delete() |
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 import forms | |
from .models import ExampleModel | |
class LocalizeMixin(object): | |
def __init__(self, *args, **kwargs): | |
super(LocalizeMixin, self).__init__(*args, **kwargs) | |
fields = self.Meta.localized_fields | |
if fields: | |
for field in 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
# coding=UTF-8 | |
from __future__ import division | |
import re | |
# This is a naive text summarization algorithm | |
# Created by Shlomi Babluki | |
# April, 2013 | |
class SummaryTool(object): |
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
git commit --amend | |
more info: http://git-scm.com/book/en/Git-Basics-Undoing-Things |
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
# O select você faz normal usando o 'using' para indicar a database específica | |
# algo como: Usuario.objects.using('database_test') | |
from django import forms | |
# ... | |
class UsuarioForm(forms.ModelForm): | |
def __init__(self, *args, **kwargs): | |
super(ContentForm, self).__init__(*args, **kwargs) | |
self.fields["user"].queryset = Usuario.objects.using('database_test') |