Autocomplete jQuery plugins tests

Specification

Write a form for selecting ‘champion’ for a project.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
#!/usr/bin/python
# -*- coding: utf8 -*-
"""The project's models.

"""
from __future__ import unicode_literals
from django.utils.encoding import python_2_unicode_compatible

from django.db import models
from django.core.urlresolvers import reverse

# https://docs.djangoproject.com/en/dev/ref/contrib/auth/#user-model
from django.contrib.auth.models import User



@python_2_unicode_compatible
class Project(models.Model):
    """A project with a title and a champion which is the foreign key to the 
       auth user.

    Documentation
    =============

    - http://guiqinqian.blogspot.fr/2012/01/using-jquery-auto-complete-in-django.html

    """
    title = models.CharField(max_length=200)
    champion = models.ForeignKey(User)

    def __str__(self):
        return "{} {}".format(self.title, self.champion)

    def get_absolute_url(self):
        """
        https://docs.djangoproject.com/en/dev/ref/class-based-views/generic-editing/
        """
        return reverse('projects:project_update',
                       kwargs={'pk': self.pk})