The model's code is below.
First thing I need is to retrieve all the places that are labelled
e.g. "tea".
So I just create a view a type:
places = Place.objects.all()
places = Place.objects.filter(primary_tags__name__contains="tea")
But then additionally I need all the places that are open now, having
the actual date and time.
And here i'm getting confused. I'm new in Django world, I used to
write in PHP+MySQL.
Can you help me?
Here's what I would do using PHP+MySQL:
1. Find the values of the "time" property of records in "Period" that
fulfill contidions: "WHERE from_date < DATE() < to_date"
2. Based on the "time" value, create the next query that check if the
place's open: "WHERE from_hour < TIME() < to_hour"
After these operation it will be possible to cut the number of result
out, and leave that places that are open, but how to achieve that in
Django?
class Tag(models.Model):
name = models.CharField(unique=True,max_length=70)
class Place(models.Model):
name = models.CharField(max_length=70)
tags = models.ManyToManyField(Tag)
class Period(models.Model):
Place = models.ForeignKey(Place)
Time = models.ForeignKey(Time,to_field="Time_number")
From_date = models.DateField()
To_date = models.DateField()
class Time(models.Model):
Time_number = models.IntegerField()
From_hour = models.TimeField()
To_hour = models.TimeField()
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---