I have a table with a list of data that I would like present to a user
and allow them to drill down into the data, but there are multiple
dimensions they may want to drill down into and I am not sure the best
way to do this with DJango URLs.
To give a bit of an example of what I am trying to do, say I have a
table of events which stores some information over time. I have
presented what I think is a reasonable way of designing URL's for
this.
Notice that this is basically single dimensional data, where the
dimension is time over which the data is to be presented:
/events/ (Lists all events over all time)
/events/YYYY-MM-DD/ (Lists all events since date)
/events/YYYY-MM-DD/YYYY-MM-DD/ (Lists all events in time range)
Also I want to allow users to optionally specify a offset + size to
any of the above so they can manually paginate the data (This is an
XML API). I am thinking the cleanest way to do this is allow optional
GET params like:
/events/?offset=0&size=100
/events/YYYY-MM-DD/?offset=0&size=100
/events/YYYY-MM-DD/YYYY-MM-DD/?offset=0&size=100
Now the tricky part comes if i want to filter on another dimension in
the data. Lets say the event is generated from a department within a
company. So we might have something like:
class Event(models.Model):
timestamp = models.DateTimeField()
company = models.CharField(max_length=128)
department = models.CharField(max_length=128)
event = models.CharField(max_length=128)
Now I was thinking of doing something like:
/events/ (Lists all events over all time, for all companies and departments)
/events/YYYY-MM-DD/ (Lists all events since date, for all companies
and departments)
/events/YYYY-MM-DD/YYYY-MM-DD/ (Lists all events in time range, for
all companies and departments)
/events/<company>/ (Lists all events over all time, for all
departments of the given company)
/events/<company>/YYYY-MM-DD/ (Lists all events since date, for all
departments of the given company)
/events/<company>/YYYY-MM-DD/YYYY-MM-DD/ (Lists all events in time
range, for all departments of the given company)
/events/<company>/<department>/ (Lists all events over all time, for
the specific department in a company)
/events/<company>/<department>/YYYY-MM-DD/ (Lists all events since
date, for the specific department in a company)
/events/<company>/<department>/YYYY-MM-DD/YYYY-MM-DD/ (Lists all
events in time range, for the specific department in a company)
Now because YYY-MM-DD is a valid company name, this scheme breaks.
Is there a more general or better way to do something like this?
Thanks,
Brendon.
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
No comments:
Post a Comment