Django Model Not Updating
<p>I'm trying to count the amount of times a user visits a page:</p>

<p>models.py:</p>

<pre><code>class Request(models.Model):
    user = models.ForeignKey(User)
    view = models.CharField(max_length = 250)
    visits = models.PositiveIntegerField()
</code></pre>

<p>views.py</p>

<pre><code>def daygaps(request,*a, **kw):

    request_counter = Request.objects.filter(
        user__username = request.user.username, view = 'daygaps')

    if request_counter:
        request_counter[0].visits += 1
        request_counter.update()

    else:
        Request.objects.create(
            user = request.user,
            visits = 1,
            view = 'daygaps')
</code></pre>

<p>When a new user visits the page for the first time, 'visits' gets set to = 1. Each subsequent visit should iterate the count. The "else" block works fine, however "visits" stays at 1 and does not change with each new request a user makes.</p>

<p>I've tried the ".save()" method, but that throws an error because "request_counter" is a queryset.</p>