Django TypeError missing 1 required positional argument: 'person_id'
<p>I'm trying to write a simple banking app using <strong>Django</strong> and I'm stuck on a strange error, missing positional argument. Any help would be much appreciated. The other templates and views work okay. The problem happens when I go to the login page.</p>

<p>The full error is:</p>

<pre><code>TypeError at /banking/login/

login() missing 1 required positional argument: 'person_id'

Request Method:     GET
Request URL:    http://127.0.0.1:8000/banking/login/
Django Version:     1.9
Exception Type:     TypeError
Exception Value:    

login() missing 1 required positional argument: 'person_id'

Exception Location:     /home/soupdragon/DJapps/env/lib/python3.4/site-
packages/django/core/handlers/base.py in get_response, line 147
Python Executable:  /home/soupdragon/DJapps/env/bin/python
Python Version:     3.4.3
Python Path:    

'/home/soupdragon/DJapps/banking/mybank',
'/home/soupdragon/DJapps/env/lib/python3.4',
'/home/soupdragon/DJapps/env/lib/python3.4/plat-i386-linux-gnu',
'/home/soupdragon/DJapps/env/lib/python3.4/lib-dynload',
'/usr/lib/python3.4',
'/usr/lib/python3.4/plat-i386-linux-gnu',
'/home/soupdragon/DJapps/env/lib/python3.4/site-packages']

Server time:    Fri, 12 Aug 2016 17:39:38 +0000
</code></pre>

<p>The stack trace is: </p>

<pre><code>Internal Server Error: /banking/login/
Traceback (most recent call last): 
File "/home/soupdragon/DJapps/env/lib/python3.4/site-packages/django
/core/handlers/base.py", line 149, in get_response
response = self.process_exception_by_middleware(e, request)
File "/home/soupdragon/DJapps/env/lib/python3.4/site-packages/django 
/core/handlers/base.py", line 147, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
TypeError: login() missing 1 required positional argument: 'person_id'
[12/Aug/2016 17:39:38] "GET /banking/login/ HTTP/1.1" 500 6010
</code></pre>

<p>The urls file:</p>

<pre><code>from django.conf.urls import url

from . import views

app_name = 'banking'
urlpatterns = [
# ex: /banking/deposit
url(r'^deposit/$', views.deposit, name='deposit'),
# ex: /banking/
url(r'^$', views.hello, name='hello'),
# ex: /banking/login
url(r'^login/$', views.login, name='login'),
# ex: /banking/transfer
url(r'^transfer/$', views.transfer, name='transfer'),
# ex: /banking/withdraw
url(r'^withdraw/$', views.withdraw, name='withdraw'),
# ex: /banking/welcome
url(r'^welcome/$', views.welcome, name='welcome'),
]
</code></pre>

<p>The models file is:</p>

<pre><code>from django.db import models

# Create your models here.
class Person(models.Model):
     first_name = models.CharField(max_length=4,default="Bob")
     last_name = models.CharField(max_length=6,default="Smith")
     login_name = models.CharField(max_length=3,default="me")
     password = models.CharField(max_length=7, default="password")
     person_text = models.CharField(max_length=10, default="Bob Smith") 

     def get_first_name(self):
         return self.first_name

     def get_last_name(self):
         return self.last_name

     def get_login_name(self):
         return self.login_name

     def get_password(self):
         return self.password

     def __str__(self):
         return self.person_text

class Account1(models.Model):
    account_number = models.IntegerField(default=12345678)
    bank_balance = models.DecimalField(max_digits=4,
    decimal_places=2,default=12.99)
    interest_rate = models.IntegerField(default=2)
    account_name = models.CharField(max_length=16, default="Current
                    Account")
    person = models.ForeignKey(Person,                     on_delete=models.CASCADE,default="") 

    def get_account_number(self):
        return self.account_number

    def get_bank_balance(self):
        return self.bank_balance

    def deposit(self, amount):
        self.bank_balance = self.bank_balance + amount
        return

    def get_interest_rate(self):
        return self.interest_rate

    def withdraw(self, amount):
        self.bank_balance = self.bank_balance - amount
        return

    #def __str__(self):
    #   return self.account_name
</code></pre>

<p>The views file is:</p>

<pre><code>from django.shortcuts import get_object_or_404, render
from django.http import HttpResponseRedirect, HttpResponse
from django.core.urlresolvers import reverse
from django.template import loader

from .models import Person, Account1

# Create your views here.
def deposit(request):
    person = Person
    account1 = Account1
    context = {'account1':account1,'person':person}
    template = loader.get_template('banking/deposit.html')
    return HttpResponse(template.render(context,request))

def hello(request):
    return HttpResponse("Hello.")

def login(request, person_id):
    person = get_object_or_404(Person, pk=person_id) 
    try:
        selected_login = person.choice_set.get(pk=request.POST['login'])
        selected_password = person.choice_set.get(pk=request.POST['password'])
    except (KeyError, Choice.DoesNotExist):
        # Redisplay the question voting form.
        return render(request, 'banking/login.html', {
            'person': person,
            'error_message': "You didn't select a choice.",
        })
    else:
        # Always return an HttpResponseRedirect after successfully dealing
        # with POST data. This prevents data from being posted twice if a
        # user hits the Back button.
        return HttpResponseRedirect(reverse('banking:welcome',
            args=(question.id,)))


def transfer(request):
    person = Person
    account1 = Account1
    context = {'account1':account1,'person':person}
    template = loader.get_template('banking/transfer.html')
    return HttpResponse(template.render(context,request))

def welcome(request):
    person = Person
    account1 = Account1
    context = {'account1':account1,'person':person}
    template = loader.get_template('banking/welcome.html')
    return HttpResponse(template.render(context,request))

def withdraw(request):
    person = Person
    account1 = Account1
    context = {'account1':account1,'person':person}
    template = loader.get_template('banking/withdraw.html')
    return HttpResponse(template.render(context,request))
</code></pre>

<p>The login template is:</p>

<pre><code>{% load staticfiles %}
 &lt;!DOCTYPE html&gt;
 &lt;html&gt;
 &lt;head&gt;
 &lt;title&gt;Deposit Money&lt;/title&gt;
 &lt;h1 id="bluetext"&gt;Please Select Account to Deposit into&lt;/h1&gt;
 &lt;meta charset="utf-8"&gt;
 &lt;meta name="viewport" content="width=device-width, initial-scale=1"&gt;
 &lt;link rel="stylesheet" href="{% static 'css/deposit.css' %}"&gt;
 &lt;link rel="stylesheet" href="http://maxcdn.bootstrapcdn.com/bootstrap
 /3.3.5/css/bootstrap.min.css"&gt;
 &lt;script src="https://ajax.googleapis.com/ajax/libs/jquery
 /1.11/jquery.min.js"&gt;&lt;/script&gt;  
 &lt;style type="text/css"&gt;&lt;/style&gt;
 &lt;/head&gt; 
 &lt;body&gt;

 &lt;div class="container-fluid" style="background-image:
 url('login.jpg'); width: 100%; height: 300px; background-size:cover;"&gt; 
 &lt;/div&gt;

&lt;form action="{% url 'banking:login' person.id %}" method="post"&gt;
&lt;fieldset&gt;
{% csrf_token %}
&lt;legend&gt;Your details:&lt;/legend&gt;
&lt;hr&gt;&lt;/hr&gt;
Username:&lt;input type="text" id="username" name="username" size="33
&lt;/input&gt;
&lt;br&gt;&lt;/br&gt;
Password:&lt;input type="text" id="password" name="password" size="33"&gt;
&lt;/input&gt;
&lt;input type="submit" name="submit" value="Submit"&gt;&lt;/input&gt;
&lt;/fieldset&gt;
&lt;/form&gt;

&lt;/body&gt;
&lt;/html&gt;
</code></pre>