Hi, I'm new to Django and just need some guidance.
Below is my attempt at creating a simple app that displays all transactions and lists the grand total called 'points' for a particular user. Now the following works and does just that, however, I'm not 100% if this is the 'correct' way nor really what a 'manager' is. Could someone look at the following code and advice? Many, many thanks O, and Happy Christmas everyone! models.py from django.db import models from django.contrib.auth.models import User class TransactionManager(models.Manager): def Transaction_list(self,thisUser): list = Transaction.objects.filter(user=thisUser) return list def points_total(self,thisUser): return Transaction.objects.filter(user=thisUser).aggregate(total_points=models.Sum('points')) class Transaction (models.Model): statusOptions = ( (0, 'Pending'), (1, 'Added'), (2, 'Deducted'), (3, 'Processing'), ) user = models.ForeignKey(User) points = models.IntegerField(verbose_name=("Points"), default=0) created = models.DateTimeField(("Created at"), auto_now_add=True) updated = models.DateTimeField(verbose_name=("Updated at"), auto_now=True) status = models.IntegerField(default=0, choices=statusOptions) objects = TransactionManager() views.py from django.template import RequestContext from django.contrib.auth.decorators import login_required from django.shortcuts import render_to_response from points.models import Transaction @login_required def history(request): thisPoints = Transaction.objects.Transaction_list(request.user) totalPoints = Transaction.objects.points_total(request.user) context = {'points':thisPoints,'totalPoints':totalPoints} return render_to_response('points/history.html', context, context_instance=RequestContext(request)) -- You received this message because you are subscribed to the Google Groups "Django users" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/rskcynXm0NAJ. 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.