Python method invovation , missing parameter
Question: Hi i'm trying to implement a profiling system so that as soon as the user logs
in, the student is identified and pulls information from the student model and
returns it to the homepage and probably every other page within the system. It
will also append the student username to the end of the URL.... hopefully

I get this error:

> profile() missing 1 required positional argument: 'username'

Urls.py

    
    
        # student urls.py
        # Import urls and patterns aswell as student views
        from django.conf.urls import patterns, url
        from student import views
    
        urlpatterns = patterns('',
        url(r'^(?P<username>[a-zA-Z0-9]+)$', views.index, name='index'),
        url(r'^$', views.profile, name='profile'))
    

Models.py

    
    
        # student models.py
        # Import the models db and validators
        # Also import user information for log in identification
        from django.db import models
        from django.core.validators import *
        from django.contrib.auth.models import User 
    
        # Specify attributes for the student database
        class student(models.Model):
        # Specify choices for years, gender and degree type
        YEARS = (
        ('1', '1st'),
        ('2', '2nd'),
        ('3', '3rd'),
        )
        GENDER = (
        ('M', 'Male'),
        ('F', 'Female'),
        )
        DEGREE = (
        ('IT', 'Information Technology'),
        ('CS', 'Computer Science'),
        )
    
        # Attributes for the student model specified here
        user = models.OneToOneField(User)
        student_ID = models.CharField(unique=True, max_length=9, validators=[RegexValidator(regex='^[0-9]{9,9}$', message='Must be 9 unique numbers', code='nomatch')])
        first_name = models.CharField(max_length=128)
        middle_name = models.CharField(max_length=128)
        last_name = models.CharField(max_length=128)
        gender = models.CharField(max_length=1, choices=GENDER)
        year = models.CharField(max_length=1, choices=YEARS)
        degree = models.CharField(max_length=2, choices=DEGREE)
        photo = models.ImageField(upload_to="profile_pictures", null=True, blank=True)
    
        def __str__(self):
                return self.student_ID
    

Views.py

    
    
        # student views.py
        # Import rendering and httpresponse
        # Also import student model
        from django.shortcuts import render
        from django.http import HttpResponse
        from student.models import student
        from extra_curricular.models import extra_curricular
        from module.models import module
        from skill.models import skill
        from django.contrib.auth.models import User
    
        # Information box displayed on each page  
        def index(request, username):
            user = User.objects.get(username=username)
            person = student.objects.get(user=user)
            return render(request, 'student/home.html', {"person":person})
    
        #Profile page information
        def profile(request, username):
             user = User.objects.get(username=username)
             person = student.objects.get(user=user)
             experience = extra_curricular.objects.get(user=user)
             module = module.objects.get(user=user)
             skill = skill.objects.get(user=user)
             return render(request, 'student/profile.html', {"person":person}, {"experience":experience}, {"module":module}, {"skill":skill})
    

Home.html

    
    
            {% block content %}
        <div class = "StudentInfoMain">
    
    
        </div>
        <div id="Options">
            <ul>
                <li><a href="/student/">Home</a></li>
                <li><a href="/extra_curricular/add_extra_curricular/">Add Information</a></li>
                <li><a href="#">View User Profile</a></li>
                <li><a href="#">Checklist</a></li>
                <li><a href="/skill/add_skill/">My Skills</a></li>
                <li><a href="/alumni/Find_Alumni/">Contact Alumni</a></li>
            </ul>
        </div>
        <div class = "Homebanner">
            <p>{{ user.username }}</p>
            <p>{{ person.student_ID }}</p>
            <p>{{ person.first_name}}</p>
            <p>{{ person.last_name }}</p>
            <p>{{ person.year }}</p>
            <p>{{ person.degree }}</p>
    
        </div>
        <div id = "Homebody">
        <p>Hello {{person.first_name}</p>
        <p>Welcome to your E-Profile</p>
        <br>
        <p>This application is intended as an aid to you during your employment endeavours.</p>
        <p>It can be used during the process of building a curriculum vitae</p>
        <p>You may add information of experiences you have had during your educational career</p>
        <br>
        <p>For any further information: </p>
        <br>
    
    
        </div>
    
    
        <footer>
    
        </footer>
        {% endblock %}
    


Answer: 
    def profile(request, username):    
    

views.profile takes an extra argument along with the request which you haven't
passed.

    
    
    url(r'^$', views.profile, name='profile')
    

