On 5/1/2009 5:47 PM, mamco wrote: > Hi, > In attempting to get a better grasp of Django, I'm attempting a fairly > simple timecard app. Multiple users of a small chain of retail > stores, where occasionally the employees jump between stores(company), > and between projects and activities. > > The interesting model is something like this: > > class Timecard(models.Model): > employee = models.ForeignKey(Employee) > company = models.ForeignKey(Company) > project = models.ForeignKey(Project) > activity = models.ForeignKey(Activity) > start = models.DateTimeField('The start time of the shift') > duration = models.DecimalField('The duration of the shift in > hours', max_digits=4, decimal_places=2) > notes = models.TextField('Special Notes on the shift') > > I've populated it with some data from a previous system (trying to > reproduce with Django), and I'm now trying to display a form which > shows a week at a time given a particular start date (which for now is > always a Sunday). > > I'm trying to show > employee, company, project on a single line followed by the totals > (summing the activity as its always 'default' for now) for Sun to Sat > and a total. > > So something like the following (pipes show columns for this post > purpose only): > J Smith | BranchA | Admin | 0.0 | 4.5 | 8.0 | 8.0 | 8.0 | 8.0 | 0.0 | > 36.5 > J Smith | BranchA | Training | 0.0 | 3.5 | 8.0 | 8.0 | 8.0 | 8.0 | 0.0 > | 36.5 > > Being new to Python and Django, I can't seem to get a function written > to kick this output out. Any pointers?
How would you approach this if you weren't using Python and Django? Is your inclination to do this using SQL or would you use an associative array of some sort in the programming language of your choice? I guess what I'm trying to say is this really doesn't have much to do with Python/Django, but is a general data pivot problem. So my advice would be to search for a solution that fits your need. It doesn't matter what the language/framework the solution is in, it's the general pattern you're after. A hint: I personally would avoid trying to do this in SQL, if nothing for the readability of the code. -- George --~--~---------~--~----~------------~-------~--~----~ 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---