Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilhermecarvalhocarneiro/c7a2d1ae02156a7ffbbd to your computer and use it in GitHub Desktop.
Save guilhermecarvalhocarneiro/c7a2d1ae02156a7ffbbd to your computer and use it in GitHub Desktop.
Classes
# Create your models here.
class Abastecimento(models.Model):
valor_etanol = models.DecimalField("Valor Etanol", max_digits=9, decimal_places=2)
valor_gasolina = models.DecimalField("Valor Gasolina", max_digits=9, decimal_places=2)
valor_diesel = models.DecimalField("Valor Diesel", max_digits=9, decimal_places=2)
usuario = models.ForeignKey(Usuario, blank=True, null=True)
posto = models.ForeignKey('Posto', blank=True, null=True)
def __unicode__(self):
return u"Posto: %s - Valores: Gas R$ %s Alc R$ %s Die R$ %s" % (self.posto, self.valor_gasolina, self.valor_etanol, self.valor_diesel)
class Cidade(models.Model):
nome = models.CharField("Nome", max_length=200, unique=True)
uf = models.CharField("UF", max_length=2)
def __unicode__(self):
return u"%s" % self.nome
class Posto(models.Model):
nome = models.CharField("Nome", max_length=200)
bandeira = models.CharField("Bandeira", max_length=200)
latitude = models.CharField("Latitude", max_length=200)
longitude = models.CharField("Longitude", max_length=200)
cidade = models.ForeignKey(Cidade)
class Meta:
unique_together = ('nome', 'cidade')
def __unicode__(self):
return u"%s" % self.nome
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment