Incorporate jQuery grid with django

2014-01-07 Thread Igor Korot
Hi, ALL,
This is my first post to this group so please bear with me for a sec.

I successfully installed django and followed the tutorial to create a 
project and an application.
It connects to my DB (mySQL) and everything is good.

Now in the part 3 of the tutorial I need to create a view.
I did create the URL in the appropriate place, but now I want to display my 
table with jQuery Grid.

So what I did is I downloaded the latest jQuery and placed it in the same 
html directory where my template is.
Now in the index.html I placed following code:

[code]

  jQuery(document).ready(function() {
jQuery("#grid").jqGrid({
  url: "displayusbtable.py",
  datatype: "local",
}).navGrid("#gridpager");
 });

[/code]

My views.py have this code:
[code]
def displayusbtable(request):
 usb_list = USB.objects.all()
 t = loader.get_template('html/index.html')
 c = Context( { 'usb_list': usb_list, } )
 returns HttpResponse(t.render(c))
[/code]

Now when I try to go to "127.0.0.1:8000/usb" I see following message:

"GET /usb/jquery-1.10.2.js HTTP/1.1" 404 2063

Checking the "Developer Tools" in IE8, I see an error in my index.html:

Obect expected: line 8 character 5
Expected identifier, string or number: line 20
I think I need to make a "usb" folder somewhere, place the jquery.js file 
there and that's it. But I don't know where this folder should be located.

Could someone please help?

Thank you.

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/75d1321f-ba3a-49ae-8967-8f88c9fe41dd%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Incorporate jQuery grid with django

2014-01-07 Thread Thomas Murphy
Hi Igor,

I'm unsure about the usb issue, but the "Django" way is to place all of
your static files in a specific directory and use the manage.py
collectstatic command, then serve them from a static location. This will
allow you to offload your statics to a CDN as your site grows.

Have a look at this part of the docs for much more info:
https://docs.djangoproject.com/en/dev/howto/static-files/


On Tue, Jan 7, 2014 at 5:14 PM, Igor Korot  wrote:

> Hi, ALL,
> This is my first post to this group so please bear with me for a sec.
>
> I successfully installed django and followed the tutorial to create a
> project and an application.
> It connects to my DB (mySQL) and everything is good.
>
> Now in the part 3 of the tutorial I need to create a view.
> I did create the URL in the appropriate place, but now I want to display
> my table with jQuery Grid.
>
> So what I did is I downloaded the latest jQuery and placed it in the same
> html directory where my template is.
> Now in the index.html I placed following code:
>
> [code]
> 
>   jQuery(document).ready(function() {
> jQuery("#grid").jqGrid({
>   url: "displayusbtable.py",
>   datatype: "local",
> }).navGrid("#gridpager");
>  });
> 
> [/code]
>
> My views.py have this code:
> [code]
> def displayusbtable(request):
>  usb_list = USB.objects.all()
>  t = loader.get_template('html/index.html')
>  c = Context( { 'usb_list': usb_list, } )
>  returns HttpResponse(t.render(c))
> [/code]
>
> Now when I try to go to "127.0.0.1:8000/usb" I see following message:
>
> "GET /usb/jquery-1.10.2.js HTTP/1.1" 404 2063
>
> Checking the "Developer Tools" in IE8, I see an error in my index.html:
>
> Obect expected: line 8 character 5
> Expected identifier, string or number: line 20
> I think I need to make a "usb" folder somewhere, place the jquery.js file
> there and that's it. But I don't know where this folder should be located.
>
> Could someone please help?
>
> Thank you.
>
>  --
> 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 http://groups.google.com/group/django-users.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/django-users/75d1321f-ba3a-49ae-8967-8f88c9fe41dd%40googlegroups.com
> .
> For more options, visit https://groups.google.com/groups/opt_out.
>

-- 
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 http://groups.google.com/group/django-users.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-users/CALgvumUO_He4CgZRjqb0pWBzhHY3iJnHStHJUcE4bSNN2eqL2g%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.