Skip to content

Instantly share code, notes, and snippets.

@JuniorLima
JuniorLima / models.py
Created May 27, 2013 11:25
Dúvida do Google Groups - Marcar objeto como destaque - http://bit.ly/14WuggW
class Video(BaseNoticia):
destaque = models.BooleanField(default=False)
url = models.CharField(max_length=15, help_text="fhbTBA64FkU")
@JuniorLima
JuniorLima / models.py
Last active December 17, 2015 11:48
A notícia tem várias categorias. Suponto que temos duas categorias cadastradas: 'Notícias' e 'Eventos'. Se a notícia tiver categoria 'Noticia', ele salva o 'id' mais o 'slugnoticia' da noticia no banco. Se ela for um evento, salva somente a 'slugnoticia'
class Categoria(models.Model):
nome = models.CharField(max_length=30)
slugcategoria = models.SlugField(max_length=100, blank=True, unique=True)
class Noticia(BaseNoticia):
titulo = models.CharField(max_length=100, unique=True)
slugnoticia = models.SlugField(max_length=200, blank=True, unique=True)
def noticia_pre_save(signal, instance, sender, **kwargs):
if instance.nomeCategoria.id == '1':
@JuniorLima
JuniorLima / colaborador.html
Created September 6, 2012 14:06
Descrição do Choices em um template Django
{{ c.cargo }}
@JuniorLima
JuniorLima / ultimas.html
Created April 26, 2012 18:24
Dúvida na paginação do Django
<div id="paginac">
<div id="botoes">
{% if notipage.has_previous %}
<a href="?page={{ notipage.previous_page_number }}">
<div id="botnBack"></div>
</a>
{% endif %}
{% if notipage.has_next %}
<a href="?page={{ notipage.next_page_number }}">
<div id="botnLeft"></div>
Quando eu entro na notícia com o link, dá certo.
http://localhost:8000/categoria/teste-de-slug
Quando eu coloco '#' no link, a notícia é exibida normalmente.
Caught NoReverseMatch while rendering: Reverse for 'Scope.views.noticiainterna' with arguments '()' and keyword arguments '{'slugnoticia': u'teste-de-slug'}' not found.
Estou achando que o erro está no models na hora de gerar a url na def get_absolute_url.