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})
|
Test the different jQuery plugins¶
- django-autocomplete-light test
- install
- tree
- projects/views_django_autocomplete_light.py
- projects/api/get_users/?q (projects/urls.py)
- projects/forms_django_autocomplete_light.py
- projects/admin.py
- Using autocompletes outside the admin
- Test URL http://127.0.0.1:8004/projects/project/1/update_django_autocomplete
- Passing options to select2
- jQuery EasyAutocomplete test
- jQuery UI autocomplete test