Skip to content

Instantly share code, notes, and snippets.

@RodolfoSilva
Created December 23, 2015 17:21
Show Gist options
  • Save RodolfoSilva/141a063e7c33c363c591 to your computer and use it in GitHub Desktop.
Save RodolfoSilva/141a063e7c33c363c591 to your computer and use it in GitHub Desktop.
from django.db import models
class Categoria(models.Model):
nome = models.CharField(max_length=200)
slug = models.SlugField(unique=True, blank=True, null=True)
parent = models.ForeignKey('self', blank=True, null=True, related_name='child')
class Produto(models.Model):
nome = models.CharField(max_length=200)
quantidade = models.IntegerField(default=0)
valor = models.DecimalField(default=0.0)
categoria = models.ForeignKey(Categoria)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment