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
#Dump de todos os models do projeto | |
python manage.py dumpdata --indent=4 > site.json | |
python manage.py dumpdata --indent=4 > initial_data.json | |
#Dump de todos os models de uma app | |
python manage.py dumpdata app --indent=4 > app.json | |
#Dump de apenas um model de uma app | |
python manage.py dumpdata app.model --indent=4 > model.json |
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
vagrant@precise64:~/.virtualenvs/djangoproj$ /home/vagrant/.virtualenvs/djangoproj/bin/pip | |
-bash: /home/vagrant/.virtualenvs/djangoproj/bin/pip: /home/vagrant/.virtualenvs/djangoproj/bin/python2.7: bad interpreter: Too many levels of symbolic links |
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 os | |
PROJECT_DIR = os.path.dirname(__file__) | |
PROJECT_ROOT_PATH = os.path.dirname(os.path.realpath(__file__)) | |
MEDIA_ROOT = os.path.join(PROJECT_DIR, '..', 'media') | |
MEDIA_URL = '/media/' | |
STATIC_ROOT = '' | |
STATIC_URL = '/static/' | |
STATICFILES_DIRS = ( | |
os.path.join(PROJECT_DIR, '..', 'static'), |
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
<!-- INICIO FORMULARIO BOTAO PAGSEGURO --> | |
<form target="pagseguro" action="https://pagseguro.uol.com.br/checkout/v2/cart.html?action=add" method="post"> | |
<input type="hidden" name="receiverEmail" value="[email protected]" /> | |
<input type="hidden" name="currency" value="BRL" /> | |
<input type="hidden" name="itemId" value="036854" /> | |
<input type="hidden" name="itemDescription" value="{{ nomedoproduto }}" /> | |
<input type="hidden" name="itemQuantity" value="{{ quantidade }}" /> | |
<input type="hidden" name="itemAmount" value="{{ precodoproduto }}" /> | |
<input type="hidden" name="itemWeight" value="" /> | |
<input type="hidden" name="itemShippingCost" value="0.00" /> |
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 ImagemAdmin(AdminImageMixin, MultiUploadAdmin): | |
list_display = ('nome', 'imagemAdmin', 'projeto') | |
list_editable = ('projeto',) | |
def process_uploaded_file(self, uploaded, object, request): | |
# example: | |
projeto_id = request.POST.get('projeto_id', ['']) | |
title = request.POST.get('title', '') or uploaded.name | |
f = FotoProjeto(nome=title, img=uploaded, projeto_id=projeto_id) | |
f.save() |
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
#user nobody; | |
worker_processes 1; | |
error_log logs/error.log; | |
#error_log logs/error.log notice; | |
#error_log logs/error.log info; | |
pid logs/nginx.pid; | |
events { |
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 FiltroManifestacoes(forms.Form): | |
dt_inicial = forms.DateTimeField(label=u'Data Inicial',widget=AdminDateWidget(format='%d/%m/%Y'), | |
input_formats='%d/%m/%Y', required=False) | |
dt_final = forms.DateTimeField(label=u'Data Final',widget=AdminDateWidget(format='%d/%m/%Y'), | |
input_formats='%d/%m/%Y', required=False) | |
def __init__(self, *args, **kwargs): | |
super(FiltroManifestacoes, self).__init__(*args, **kwargs) | |
self.fields['dt_inicial'].input_formats = ['%d/%m/%Y'] | |
self.fields['dt_final'].input_formats = ['%d/%m/%Y'] |
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
# coding: utf-8 | |
#!/usr/bin/env python | |
from django.conf import settings | |
from django.contrib.auth import models as auth_models | |
from django.contrib.auth.management import create_superuser | |
from django.db.models import signals | |
signals.post_syncdb.disconnect( | |
create_superuser, | |
sender=auth_models, |
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 MyModelAdmin(admin.ModelAdmin): | |
def queryset(self, request): | |
qs = super(MyModelAdmin, self).queryset(request) | |
if request.user.is_superuser: | |
return qs | |
return qs.filter(author=request.user) |