Simple Django App to pull data from http://www.mvg-live.de and to store them in the Database. The Name of the stations can be configured via the Admin UI and there is a Admin command to pull the data via Cron.

models.py 946B

123456789101112131415161718192021222324
  1. from django.db import models
  2. class Station(models.Model):
  3. name = models.CharField(max_length=30)
  4. last_update = models.DateTimeField(default=None, blank=True, null=True)
  5. def __unicode__(self):
  6. return self.name
  7. class DepartureTime(models.Model):
  8. Station = models.ForeignKey(Station, null=True, default=None)
  9. product = models.CharField(max_length=10, blank=False, null=False)
  10. line = models.CharField(max_length=10, blank=False, null=False)
  11. destination = models.CharField(max_length=50, blank=False, null=False)
  12. linesymbolurl = models.CharField(max_length=250, blank=True, null=True)
  13. productsymbolurl = models.CharField(max_length=250, blank=True, null=True)
  14. time = models.IntegerField(null=False, blank=False, default=-1)
  15. last_update = models.DateTimeField(auto_now=True)
  16. class Meta:
  17. unique_together = ('Station', 'product', 'line', 'destination', 'time')