'Helper function to create the url'

def get_url(self, username):

    base_url = reverse(self.namespaced_url, kwargs={'course_id': self.course_key})
    query_string = ''
    if username:
        query_string = ('?' + urlencode(dict(username=username)))
    return (base_url + query_string)
