Skip to content

Commit

Permalink
Altera representação textual de objeto com método especial
Browse files Browse the repository at this point in the history
  • Loading branch information
brnocesar committed Nov 8, 2020
1 parent e157988 commit 79a272e
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 2 deletions.
3 changes: 3 additions & 0 deletions apps/pessoas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,3 +3,6 @@
class Pessoa(models.Model):
nome = models.CharField(max_length=200)
email = models.CharField(max_length=200)

def __str__(self):
return self.nome
3 changes: 3 additions & 0 deletions apps/receitas/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,6 @@ class Receita(models.Model):
rendimento = models.CharField(max_length=100)
categoria = models.CharField(max_length=100)
data_criacao = models.DateTimeField(default=datetime.now, blank=True)

def __str__(self):
return self.nome
2 changes: 1 addition & 1 deletion apps/receitas/templates/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
<img src="{% static 'img/bg-img/foto_receita.png' %}" alt="">
<div class="receipe-content">
<a href="{% url 'receita' receita.id %}">
<h5>{{ receita.nome }}</h5>
<h5>{{ receita }}</h5>
</a>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion apps/receitas/templates/receita.html
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ <h2>{{receita.nome}}</h2>
<h6>Preparo: {{receita.tempo_preparo}}</h6>
<h6>Rendimento: {{receita.rendimento}}</h6>
<h6>Categoria: {{receita.categoria}}</h6>
<h6>Por: Pessoa</h6>
<h6>Por: {{receita.pessoa}}</h6>
</div>
</div>
</div>
Expand Down

0 comments on commit 79a272e

Please sign in to comment.