Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-26 Thread Sajid Samsad
Could you kindly suggest me some autocomplete library which I can use for 
my Django Project? My deadline is coming fast and furiously and I have 
already spent too much time on this autocomplete library `Select2`. 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/aedbaee1-737e-46c1-a6c8-7563d007376d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-26 Thread Jason
looks like something you should go to the select2 github issue tracker for, 
since this is not a django issue.  

In the meantime, try using the unminified version of select2, would be a 
more relevant stack trace for you to look through the errors without the 
transformed names.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/a09559e2-ca16-435f-b0c8-b60ad12f393d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-26 Thread Sajid Samsad

>
> I actually didn't understand your question. 
>
>  

> I have posted the codes above. 
>
>  

> Could you kindly take a look if it's anything with the code?your question.
>
>
I actually didn't understand your question. I have posted the codes above. 
Could you kindly take a look if it's to anything with the codes?

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/83df68d9-2d16-4f9f-a74a-bd37f4b14259%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-26 Thread Jason
As you can see at https://select2.org/data-sources/ajax#jquery-ajax-options, 
ajax parameters are passed to a jquery method.  So do you have a 

Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-26 Thread Sajid Samsad

>
> Well when I write something in the search options, I got this error:
>
>

But I didn't write the js. It is from select2.
And if the request is not hit then what should I write?
The request for the API is localhost:8000/api.alife-marine/search/products
 

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/eb08e04b-03ef-4a0d-8be5-a49dd1265a63%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-26 Thread Jason
That;s not quite what I mean 


See above, there's a XHR (ajax) request going to reddit and you can see the 
headers of the request/response as well as the data sent back.  What do you 
see of this when you call your search api?

Because it seems to me your request isn't being hit in the server from the 
client code





On Monday, December 25, 2017 at 8:28:37 PM UTC-5, Sajid Samsad wrote:
>
> To @Jason
>>
>> 1) Yeah. I used the url from the browser and it worked. Actually the 
> whole url is
> localhost:8000//api.alif-marine.com/search/products?q=product_name
> As
> ?q=whatever I type 
> is supposed to be added by javascript so when I am manually doing this 
> from my browser, I am using the above url.
>
> 2) Well I used `//` but didn't work
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/695127be-15d3-4224-a561-37719385850d%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-25 Thread Sajid Samsad

>
> To @Jason
>
> 1) Yeah. I used the url from the browser and it worked. Actually the whole 
url is
localhost:8000//api.alif-marine.com/search/products?q=product_name
As
?q=whatever I type 
is supposed to be added by javascript so when I am manually doing this from 
my browser, I am using the above url.

2) Well I used `//` but didn't work

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/7e44fb83-33ec-47d2-aac1-aa1f99390f42%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-25 Thread Sajid Samsad


On Monday, December 25, 2017 at 8:51:46 PM UTC+6, Sajid Samsad wrote:
>
>
> In my Django project, I have a Search field. I used Select2 autocomplete with 
> it. I needed to fetch the product_list from my Product model. So I created a 
> rest API that returns the product in json formats.
>
> Here is my rest API code:
>
> *serializer.py*:
>
> class ProductSerializer(serializers.ModelSerializer):
> class Meta:
> model = ProductList
> fields = ('product_id', 'product_name', 'product_image', 
> 'product_available',
>   'product_description')
>
> *views.py*:
>
> class JSONResponse(HttpResponse):
> def __init__(self, data, **kwargs):
> content = JSONRenderer().render(data)
> kwargs['content_type'] = 'application/json'
> super(JSONResponse, self).__init__(content, **kwargs)
>
> def list(request):
> if request.method == 'GET':
> products = 
> ProductList.objects.filter(product_name__icontains=request.GET.get('q'))
> serializer = ProductSerializer(products, many=True)
> serializer_data = serializer.data
> customData = {'results': serializer_data}
> return JSONResponse(customData)
>
> Now in my html, in the javascript portion I used this code mentioned in this 
> Select2 doc . 
> The code I used, looks like this:
>
> *base.html*:
>
> 
> $(document).ready(function() {
> $('.js-data-example-ajax').select2({
> ajax: {
> url: "/api.alif-marine.com/search/products",
> dataType: 'json',
> delay: 250,
> type: 'GET',
> data: function (params) {
> return{
> q: params.term, // search term
> page: params.page
> };
> },
> processResults: function (data, params) {
> params.page = params.page || 1;
>
> return {
> results: data.results,
> };
> },
> cache: true
> },
> placeholder: 'Search for a product',
> escapeMarkup: function (markup) { return markup; }, // let 
> our custom formatter work
> minimumInputLength: 1,
> templateResult: formatRepo,
> templateSelection: formatRepoSelection
> });
> function formatRepo (repo) {
> if (repo.loading) {
> return repo.text;
> }
>
> var markup = "
" +{#"
class='select2-result-repository__avatar'>
" +#} > "
" + > "
" + > repo.product_name + "
"; > > if (repo.product_description) { > markup += "
class='select2-result-repository__description'>" + repo.product_description + > "
"; > } > > return markup; > } > > function formatRepoSelection (repo) { > return repo.product_name || repo.text; > } > }); > > > When I used Postman to check if the rest API works or not, it worked > perfectly. For my query in the Postman like these: > > localhost:8000/api.alif-marine.com/search/products?q=t > > or > > localhost:8000/api.alif-marine.com/search/products?q=tho > > or > > localhost:8000/api.alif-marine.com/search/products?q=thomas > > The retrieved json data is given below for query localhost:8000/ > api.alif-marine.com/search/products?q=t : > > { >"results":[ > { > "product_id":9, > "product_name":"thomas", > "product_image":"/media/media/tom_dushtu.jpg", > "product_available":"available", > "product_description":"jah dushtu" > }, > { > "product_id":8, > "product_name":"ami dissapointed", > "product_image":"/media/media/dissapointment.jpg", > "product_available":"available", > "product_description":"I ma kinda dissapointed, you > know.." > } >]} > > Now with all those, I couldn't make it work. The autocomplete is not > working. Nothing is shown when I press one key or write the name of the > whole product. > > [image: Here is an image] . It > always has shown Searching I tried reading the issues on the Github repo > and some other things but couldn't solve it. > > What am I doing wrong? > > -- You received this message because you are subscribed to the

Re: Using Select2 autocomplete with Django project does not work while fetching the data

2017-12-25 Thread Jason
Couple questions:

Do you see the request going from the browser to the server and back?  Not 
using postman, but your browser dev tools network tab

you have just a `/` at your ajax url.  Shouldn't this be `//` for 
protocol-agnostic?


-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/c7a30c46-4892-428f-bfd8-5f1f2db0bb28%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Autocomplete in Django

2017-09-18 Thread Melvyn Sopacua
Then you need to learn Ajax.
You can't do dynamic forms like this and not use Ajax.

I linked django-autocomplete-light for a reason: if you follow the
docs and use it, you can build things you need without knowing Ajax.
However, if it doesn't work or is creating problems because of
incorrect input, it is vital you know the foundation of Ajax to
troubleshoot.

On Sun, Sep 17, 2017 at 11:27 PM, Mreno sert <zent...@gmail.com> wrote:
> Thanks for the help...but I do not know ajax. Is there anything simpler like
> I heard about "create-field" option. Tried it , but not getting it done
> correctly.
>
> On Sunday, September 17, 2017 at 3:00:14 PM UTC+5:30, Andréas Kühne wrote:
>>
>> That really depends on how you want it to work?
>>
>> I would probably add an item on the dropdown that shows the current items
>> in the database, with "Add city". If the user presses that you can have an
>> AJAX call that adds the item to the database.
>>
>> Regards,
>>
>> Andréas
>>
>> 2017-09-17 6:23 GMT+02:00 Mreno sert <zen...@gmail.com>:
>>>
>>> I have a small app in which I have form for taking 5 inputs as City1,
>>> City2,City3,City4 and City5 as the fields. I have written a code for auto
>>> completing it but A user can not enter the new fields. Only existing values
>>> can be used. How can I make it to accept a new field if not present in the
>>> database
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To unsubscribe from this group and stop receiving emails from it, send an
>>> email to django-users...@googlegroups.com.
>>> To post to this group, send email to django...@googlegroups.com.
>>> Visit this group at https://groups.google.com/group/django-users.
>>> To view this discussion on the web visit
>>> https://groups.google.com/d/msgid/django-users/0e9d44e3-156b-4f5d-80da-5a0cfd0930d5%40googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>>
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/2088e144-e2f5-4351-a9d8-62954467da06%40googlegroups.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 
Melvyn Sopacua

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Bgw1GXCLsnb0Bzo9m3EJNWBYGXPSL91PZTBGH%3Dj39RJCtTusA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Autocomplete in Django

2017-09-17 Thread Mreno sert
Thanks for the help...but I do not know ajax. Is there anything simpler 
like I heard about "create-field" option. Tried it , but not getting it 
done correctly.

On Sunday, September 17, 2017 at 3:00:14 PM UTC+5:30, Andréas Kühne wrote:
>
> That really depends on how you want it to work?
>
> I would probably add an item on the dropdown that shows the current items 
> in the database, with "Add city". If the user presses that you can have an 
> AJAX call that adds the item to the database.
>
> Regards,
>
> Andréas
>
> 2017-09-17 6:23 GMT+02:00 Mreno sert :
>
>> I have a small app in which I have form for taking 5 inputs as City1, 
>> City2,City3,City4 and City5 as the fields. I have written a code for auto 
>> completing it but A user can not enter the new fields. Only existing values 
>> can be used. How can I make it to accept a new field if not present in the 
>> database
>>
>> -- 
>> You received this message because you are subscribed to the Google Groups 
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an 
>> email to django-users...@googlegroups.com .
>> To post to this group, send email to django...@googlegroups.com 
>> .
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit 
>> https://groups.google.com/d/msgid/django-users/0e9d44e3-156b-4f5d-80da-5a0cfd0930d5%40googlegroups.com
>>  
>> 
>> .
>> For more options, visit https://groups.google.com/d/optout.
>>
>
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/2088e144-e2f5-4351-a9d8-62954467da06%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


Re: Autocomplete in Django

2017-09-17 Thread Melvyn Sopacua
In particular, you need to override the ModelChoiceField that a
ModelForm creates automatically and replace it with a field that is
not based  on ChoiceField at all or skips it's validation method (like
https://github.com/yourlabs/django-autocomplete-light/blob/master/src/dal_select2/fields.py#L34).

On Sun, Sep 17, 2017 at 11:35 AM, Jani Tiainen <rede...@gmail.com> wrote:
> Hi.
>
> Besides the way Andréas described, there exist autocomplete fields that can
> accept arbitrary input you can send to backend without having to create
> special add phase.
>
> Adding such functionality of course requires a custom field that can add
> nonexisting values to database.
>
>
> 17.9.2017 7.40 "Mreno sert" <zent...@gmail.com> kirjoitti:
>>
>> I have a small app in which I have form for taking 5 inputs as City1,
>> City2,City3,City4 and City5 as the fields. I have written a code for auto
>> completing it but A user can not enter the new fields. Only existing values
>> can be used. How can I make it to accept a new field if not present in the
>> database
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To unsubscribe from this group and stop receiving emails from it, send an
>> email to django-users+unsubscr...@googlegroups.com.
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at https://groups.google.com/group/django-users.
>> To view this discussion on the web visit
>> https://groups.google.com/d/msgid/django-users/0e9d44e3-156b-4f5d-80da-5a0cfd0930d5%40googlegroups.com.
>> For more options, visit https://groups.google.com/d/optout.
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/CAHn91odu2EUFBMSUX0CfX2f6in%2BHOUMDnAwkT8-nKPUaOGCnxw%40mail.gmail.com.
>
> For more options, visit https://groups.google.com/d/optout.



-- 
Melvyn Sopacua

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CA%2Bgw1GXVXmzDpOw1GmkevNJkYJDrPm1kDccLQ8919cT0OZC%2BTA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Autocomplete in Django

2017-09-17 Thread Jani Tiainen
Hi.

Besides the way Andréas described, there exist autocomplete fields that can
accept arbitrary input you can send to backend without having to create
special add phase.

Adding such functionality of course requires a custom field that can add
nonexisting values to database.


17.9.2017 7.40 "Mreno sert"  kirjoitti:

> I have a small app in which I have form for taking 5 inputs as City1,
> City2,City3,City4 and City5 as the fields. I have written a code for auto
> completing it but A user can not enter the new fields. Only existing values
> can be used. How can I make it to accept a new field if not present in the
> database
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/0e9d44e3-156b-4f5d-80da-5a0cfd0930d5%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAHn91odu2EUFBMSUX0CfX2f6in%2BHOUMDnAwkT8-nKPUaOGCnxw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: Autocomplete in Django

2017-09-17 Thread Andréas Kühne
That really depends on how you want it to work?

I would probably add an item on the dropdown that shows the current items
in the database, with "Add city". If the user presses that you can have an
AJAX call that adds the item to the database.

Regards,

Andréas

2017-09-17 6:23 GMT+02:00 Mreno sert :

> I have a small app in which I have form for taking 5 inputs as City1,
> City2,City3,City4 and City5 as the fields. I have written a code for auto
> completing it but A user can not enter the new fields. Only existing values
> can be used. How can I make it to accept a new field if not present in the
> database
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to django-users+unsubscr...@googlegroups.com.
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at https://groups.google.com/group/django-users.
> To view this discussion on the web visit https://groups.google.com/d/
> msgid/django-users/0e9d44e3-156b-4f5d-80da-5a0cfd0930d5%40googlegroups.com
> 
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CAK4qSCcwa26V0v2Z-UK1QEUnx8nRD86_VhpkjAke4Hc41t%2BVaw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Autocomplete in Django

2017-09-16 Thread Mreno sert
I have a small app in which I have form for taking 5 inputs as City1, 
City2,City3,City4 and City5 as the fields. I have written a code for auto 
completing it but A user can not enter the new fields. Only existing values 
can be used. How can I make it to accept a new field if not present in the 
database

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-users+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/0e9d44e3-156b-4f5d-80da-5a0cfd0930d5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.


AutoComplete With Django

2012-04-02 Thread furqanmlk
Hi there,

Sorry for posting this question even it had been answered but i tried
all my best to solve this issue,
if use result list in Jquery code directly it works.

Here is code,
HTML:

  
Type 
Something:

  
 

Jquery:
$(document).ready(function(){
$("#searchbox").autocomplete({

 source: '{% url AutoCompleteSearch %}',
 minLength: 2

});

});


View.py:

def AutoCompleteSearch(request):
#query = request.Get.get("q","")

   #For Testing
results = []

results = [
 "ActionScript",
 "AppleScript",
 "Asp",
 "BASIC",
 "C",
 "C++",
 "Clojure",
 "COBOL",
 "ColdFusion",
 "Erlang",
 "Fortran",
 "Groovy blah",
 "Haskell",
 "Java",
 "JavaScript",
 "Lisp",
 "Perl",
 "PHP",
 "Python",
 "Ruby",
 "Scala",
 "Scheme"
 ]


json = simplejson.dumps(results)
return HttpResponse(json, mimetype='application/json')

url.py:

url(r'^AutoCompleteSearch/$', AutoCompleteSearch),



Your help would greatle be appreciated.

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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.



Re: JQuery Autocomplete in Django Not Working

2009-04-09 Thread Charleno Pires

Use firebug to see if loading jquery. If not loading Jquery.
Try this in your terminal.

I'm using Ubuntu 8.04, but the path depends of your system operating.

export PYTHONPATH=/home/user/directory_of_your_project
export DJANGO_SETTINGS_MODULE=your_project.settings
django-admin.py runserver --adminmedia=/home/user/
directory_of_your_project/your_project/media/

On Apr 9, 10:17 am, Karen Tracey <kmtra...@gmail.com> wrote:
> On Thu, Apr 9, 2009 at 7:33 AM, Tomas Zulberti <tzulbe...@gmail.com> wrote:
>
> > On Thu, Apr 9, 2009 at 3:16 AM, Gath <pgath...@gmail.com> wrote:
>
> > > Guys,
>
> > > I have the following code from some example i got from
> > > here:
> >http://lethain.com/entry/2007/dec/01/using-jquery-django-autocomplete...
> > ,
>
> > > but its not working on my django application.
>
> > > On my templete i have this function:
>
> > > $(function(){ setAutoComplete("tags", "tagResults", "/taglookup/?
> > > query=");taglookup/?query=test 404 NOT FOUND });
>
> > > and on my urls i have the following line
>
> > > (r'^taglookup/$', 'twine.twineapp.views.tag_lookup'),
>
> > > and my view looks like this:
>
> > > def tag_lookup(request):
> > >    # 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 = Book.objects.filter
> > > (name__icontains=value)
> > >                TaggedItem = Tag.objects.get_by_model(Question,
> > > Tag.objects.filter(name__in=[value]))
> > >                results = [ x.name for x in TaggedItem]
> > >    json = simplejson.dumps(results)
> > >    return HttpResponse(json, mimetype='application/json')
>
> > > When i try to type anything on my "tags" field in the template,
> > > firebug gives me the following error;
>
> > > GEThttp://127.0.0.1:8000/taglookup/?query=test404 NOT FOUND
> > > JQuery-1.3.2.js (line 3633)
>
> > > Any ideas where am goofing?
>
> > > Gath
>
> > The url for the view is r'^taglookup/$, meaning that the spacified url
> > should end with /$.In you case the complete url is:
> > taglookup/?query=test so, the regular expresion isn't corrert.
>
> > A quick fix should be to addd something like taglookup/.*
>
> This is incorrect.  Any querystring present in the request (?query=test for
> this example) is not part of the url matching step.
>
> What happens when you enter that url, exactly as reported from the 404 NOT
> FOUND, in a browser address bar? Perhaps the detailed debug page of what
> urls are being tried to match against what will give a clue as to why what
> looks like it should be matching isn't.
>
> Karen
--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~--~~~~--~~--~--~---



Re: JQuery Autocomplete in Django Not Working

2009-04-09 Thread Karen Tracey
On Thu, Apr 9, 2009 at 7:33 AM, Tomas Zulberti <tzulbe...@gmail.com> wrote:

>
> On Thu, Apr 9, 2009 at 3:16 AM, Gath <pgath...@gmail.com> wrote:
> >
> >
> > Guys,
> >
> > I have the following code from some example i got from
> > here:
> http://lethain.com/entry/2007/dec/01/using-jquery-django-autocomplete-fields
> ,
> >
> > but its not working on my django application.
> >
> > On my templete i have this function:
> >
> > $(function(){ setAutoComplete("tags", "tagResults", "/taglookup/?
> > query=");taglookup/?query=test 404 NOT FOUND });
> >
> > and on my urls i have the following line
> >
> > (r'^taglookup/$', 'twine.twineapp.views.tag_lookup'),
> >
> > and my view looks like this:
> >
> > def tag_lookup(request):
> ># 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 = Book.objects.filter
> > (name__icontains=value)
> >TaggedItem = Tag.objects.get_by_model(Question,
> > Tag.objects.filter(name__in=[value]))
> >results = [ x.name for x in TaggedItem]
> >json = simplejson.dumps(results)
> >return HttpResponse(json, mimetype='application/json')
> >
> > When i try to type anything on my "tags" field in the template,
> > firebug gives me the following error;
> >
> > GET http://127.0.0.1:8000/taglookup/?query=test 404 NOT FOUND
> > JQuery-1.3.2.js (line 3633)
> >
> > Any ideas where am goofing?
> >
> > Gath
>
> The url for the view is r'^taglookup/$, meaning that the spacified url
> should end with /$.In you case the complete url is:
> taglookup/?query=test so, the regular expresion isn't corrert.
>
> A quick fix should be to addd something like taglookup/.*
>

This is incorrect.  Any querystring present in the request (?query=test for
this example) is not part of the url matching step.

What happens when you enter that url, exactly as reported from the 404 NOT
FOUND, in a browser address bar? Perhaps the detailed debug page of what
urls are being tried to match against what will give a clue as to why what
looks like it should be matching isn't.

Karen

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~--~~~~--~~--~--~---



Re: JQuery Autocomplete in Django Not Working

2009-04-09 Thread Tomas Zulberti

On Thu, Apr 9, 2009 at 3:16 AM, Gath <pgath...@gmail.com> wrote:
>
>
> Guys,
>
> I have the following code from some example i got from
> here: 
> http://lethain.com/entry/2007/dec/01/using-jquery-django-autocomplete-fields,
>
> but its not working on my django application.
>
> On my templete i have this function:
>
> $(function(){ setAutoComplete("tags", "tagResults", "/taglookup/?
> query=");taglookup/?query=test 404 NOT FOUND });
>
> and on my urls i have the following line
>
> (r'^taglookup/$', 'twine.twineapp.views.tag_lookup'),
>
> and my view looks like this:
>
> def tag_lookup(request):
># 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 = Book.objects.filter
> (name__icontains=value)
>TaggedItem = Tag.objects.get_by_model(Question,
> Tag.objects.filter(name__in=[value]))
>results = [ x.name for x in TaggedItem]
>json = simplejson.dumps(results)
>return HttpResponse(json, mimetype='application/json')
>
> When i try to type anything on my "tags" field in the template,
> firebug gives me the following error;
>
> GET http://127.0.0.1:8000/taglookup/?query=test 404 NOT FOUND
> JQuery-1.3.2.js (line 3633)
>
> Any ideas where am goofing?
>
> Gath

The url for the view is r'^taglookup/$, meaning that the spacified url
should end with /$.In you case the complete url is:
taglookup/?query=test so, the regular expresion isn't corrert.

A quick fix should be to addd something like taglookup/.*

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~--~~~~--~~--~--~---



JQuery Autocomplete in Django Not Working

2009-04-09 Thread Gath


Guys,

I have the following code from some example i got from
here: 
http://lethain.com/entry/2007/dec/01/using-jquery-django-autocomplete-fields,

but its not working on my django application.

On my templete i have this function:

$(function(){ setAutoComplete("tags", "tagResults", "/taglookup/?
query="); });

and on my urls i have the following line

(r'^taglookup/$', 'twine.twineapp.views.tag_lookup'),

and my view looks like this:

def tag_lookup(request):
# 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 = Book.objects.filter
(name__icontains=value)
TaggedItem = Tag.objects.get_by_model(Question,
Tag.objects.filter(name__in=[value]))
results = [ x.name for x in TaggedItem]
json = simplejson.dumps(results)
return HttpResponse(json, mimetype='application/json')

When i try to type anything on my "tags" field in the template,
firebug gives me the following error;

GET http://127.0.0.1:8000/taglookup/?query=test 404 NOT FOUND
JQuery-1.3.2.js (line 3633)

Any ideas where am goofing?

Gath

--~--~-~--~~~---~--~~
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@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
-~--~~~~--~~--~--~---