# Create your models here. from django.db import models STATE_CHOICES = (('wish', 'wish'),('planned','planned'),('up','up'),('down','down')) class Point(models.Model): name = models.CharField(max_length=100) lat = models.DecimalField(max_digits=10, decimal_places=6) lon = models.DecimalField(max_digits=10, decimal_places=6) neighbors = models.ManyToManyField('self', through='Link', symmetrical=False) state = models.CharField(max_length=20, choices=STATE_CHOICES, default='planned') comment = models.TextField(max_length=1000) def __unicode__(self): return self.name class Link(models.Model): master = models.ForeignKey(Point, related_name='master', on_delete=models.CASCADE) slave = models.ForeignKey(Point, related_name='slave', on_delete=models.CASCADE) state = models.CharField(max_length=20, choices=STATE_CHOICES, default='planned') comment = models.TextField(max_length=1000) def __unicode__(self): return "%s - %s" % (self.master, self.slave)