I have the following model
class Team(models.Model):
name = models.CharField(max_length=100)
members = models.ManyToManyField(User, related_name="members", blank=True, null=True)
And the following view (controller)
def my_teams(request):
my_list = Team.objects.filter(members=request.user).order_by('name')
return render_to_response('teams/index.html', {'my_list': my_list})
This works fantastic when a user is logged in, but I receive the following error while testing as an Anonymous user.
Exception Value: int() argument must be a string or a number, not 'AnonymousUser'
How do I cater for Anonymous users? Is this handled in my template or view?
Any advice on how to achieve this would be greatly appreciated.