http://docs.djangoproject.com/en/dev/topics/db/queries/
On Apr 23, 11:11 am, Pep <pepourqu...@gmail.com> wrote: > Hi everybody ! > > I have two tables on my database : one for the products (named > Product) and one for my clients (name Client). > In Client, there is a row named 'products' where I put all the client > products with a list and a dictionnary. > For exemple : list = ["prod1": {"name"="product1", "price"=2}, > "prod2":{"name"="product2", "price"=3}] > > I want to autocomplete a field with Jquery with the table Product. > So I wrote (ok ! copy :p) this function : > > def lookup_product(request, name): > # Default return list > results = [] > if request.method == "GET": > if request.GET.has_key(u'query'): > value = request.GET[u'query'] > # Ignore queries shorter than length 3 > if len(value) > 2: > model_results = > Product.objects.filter(name__icontains=value) > results = [ x.name for x in model_results ] > json = simplejson.dumps(results) > return HttpResponse(json, mimetype='application/json') > > However, I want to filter the table Product with all the client > products. > > Does anybody have an idea to do it ? > I thought on something like that : add in filter "name is present on > list" where list is the client products list. What's your opinion ? > > Thanks > > PEP > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To post to this group, send email to django-us...@googlegroups.com. > To unsubscribe from this group, send email to > django-users+unsubscr...@googlegroups.com. > For more options, visit this group > athttp://groups.google.com/group/django-users?hl=en. -- You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-us...@googlegroups.com. To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-users?hl=en.