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
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
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
#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
class MyModelAdmin(admin.ModelAdmin): | |
def get_fieldsets(self, request, obj=None): | |
if obj: | |
return [(None, {'fields': ('field_c', 'field_b')})] | |
return [(None, {'fields': ('field_a', 'field_b', 'field_c')})] | |
def get_form(self, request, obj=None, **kwargs): | |
if obj: | |
defaults = {'exclude': ('field_a',)} | |
else: |
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 VideoAdmin(admin.ModelAdmin): | |
class Media: | |
js = ('/js/tiny_mce/tiny_mce.js', '/js/textareas.js') | |
fieldsets = [ | |
('Principais', {'fields':(('publicar'),('titulo'),'subtitulo', ('conteudo'),)}), | |
('Mídia', {'fields':('url','imagem')}), | |
] | |
list_display = ['titulo', 'cliques'] | |
list_filter = ['publicar'] | |
search_fields = ['titulo'] |
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 BaseNoticia(models.Model): | |
publicar = models.BooleanField(default=True) | |
destaque = models.BooleanField(default=False) | |
titulo = models.CharField(max_length=100, unique=True) | |
conteudo = models.TextField('Conteúdo') | |
slug = models.SlugField(max_length=150, blank=True, unique=True) | |
criado_em = models.DateTimeField(auto_now_add=True) | |
atualizado_em = models.DateTimeField(auto_now=True) | |
cliques = models.IntegerField('Cliques', default=0, editable=False) |
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 Galeria(models.Model): | |
publicar = models.BooleanField(default=True) | |
destaque = models.BooleanField(default=False) | |
nome = models.CharField(max_length=30) | |
class Foto(models.Model): | |
img = ImageField('Imagem do projeto', upload_to=rename_file_and_upload_to) | |
galeria = models.ForeignKey(Galeria, blank=True, null=True) |
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 noticia(request, slugcategoria, slug): | |
# Trago a noticia | |
noticia = get_object_or_404(Noticias, categoria_nome__slugcategoria=slugcategoria, slug=slug, publicar=True) | |
# Trago a relacionada | |
relacionados = Noticias.objects.filter(categoria_nome=noticia.categoria_nome).exclude(pk=noticia.pk).order_by('-criado_em')[:5] | |
# Quero trazer as ultimas, menos as relacionadas. Aqui é o erro | |
ultimas = Noticias.objects.filter(publicar=True).exclude(id=relacionados).order_by('-criado_em')[:5] | |
return render_to_response('juvenis/noticia.html',locals(),context_instance=RequestContext(request)) |