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?
I'm new to both python and django as well, but how about writing a presentation method and mention that method in the list_display of the admin interface, something like... class Timecard(models.Model): employee... ... notes... def get_week_result(self): # make a result string like '0.0 4.5 8.0 8.0 ...etc. # The 'start' field contains the weekday. # or maybe one method for each day of the week. return result class TimecardAdmin(admin.ModelAdmin): ... list_display = ('employee', ..., 'get_week_result') ... However, the model you defined is slightly askew from your presentation, if you want to look at a week at a time, maybe you'd be better of defining the model/record as being a week. Simply make things easier on yourself. Just my 2c /Lars Stavholm --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---