Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Trail(models.Model):
- '''
- Main model for this application. Contains all information for a particular trail
- '''
- trail_name = models.CharField(max_length=150)
- active = models.BooleanField(default=True)
- date_uploaded = models.DateTimeField(default=now())
- owner = models.ForeignKey(Account, default=1)
- class Surface(models.Model):
- '''
- A many to many join table to map a surface type to many trails. A trail can have many
- surface types.
- '''
- type = models.CharField(max_length=50, db_column='surface_type', unique=True)
- trails = models.ManyToManyField(Trail)
- class Meta:
- ordering = ('type', )
- from django.models.db import Q
- queries = [Q(type = surface) for surface in request.GET.getlist('keys')]
- query = queries.pop()
- for item in queries:
- query |= item
- results = Trail.objects.filter(surface=type)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement