[no subject]

2014-05-03 Thread Igor Korot
Hi, ALL,
This is my first official post here so be gentle... ;-)

I'm trying to make an application based on the following db structure:

table 1: id - primary key, fname char(40), lname char(40)
table 2: id - primary key, position char(20)
table 3: table1_id, table2_id - foreign key

Now, from what I understand Django does not work well with tables
without PK. So in order to make it around it just makes a bogus
primary key in the table called id.

What I'd like to know is this: there is no point of creating a PK for
a table 3. In fact it is wrong as it completely destroys the purpose
of the db schema.
Can I prevent the creation of the PK in this one table somehow? If its
not possible, is there a place where I can submit this as a
bug/feature request?

Thank you for any help.

-- 
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/CA%2BFnnTyii-umGTL%3D81PWWQP07ubyheZfTzmT5p%2Bzide-T0FvhA%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.


Re: JSON serialization

2014-01-18 Thread Igor Korot
Hi, Babatunde,

On Sat, Jan 18, 2014 at 8:32 AM, Babatunde Akinyanmi
<tundeba...@gmail.com> wrote:
> Thats probably because you are returning the json as a context in a response
> with the default "text/html" mime type. Your response should have mime type
> as " application/javascript".
> Your json data should be in the response

How do I do that? Could you give me some code, please?
Or at least point to the docs...

Thank you.

>
> On 18 Jan 2014 09:16, "Igor Korot" <ikoro...@gmail.com> wrote:
>
> Hi, guys,
>
> On Sat, Jan 18, 2014 at 12:02 AM, Babatunde Akinyanmi
> <tundeba...@gmail.com> wrote:
>>
>> On 18 Jan 2014 08:32, "Mario Gudelj" <mario.gud...@gmail.com> wrote:
>>>
>>> In your template try {{usb_data|safe}}
>>
>> ...because django escapes everything in the template by default except
>> you ask not to. One of the methods of doing so if by using the `safe`
>> filter
>> like Mario suggested.
>> You can read the documentation on how to escape or unescape stuff in your
>> template.
>
> Thank you, guys. It works.
> Now I need to figure out why I still don't see my data in the jQWidget
> control (jqxGrid)...
>
> Anybody familiar with this library?
>
> Thank you.
>>
>>>
>>> On 18/01/2014 4:53 pm, "Igor Korot" <ikoro...@gmail.com> wrote:
>>>>
>>>> Hi, ALL,
>>>> I'd like someone to help me understand this situation.
>>>> Looking at the page:
>>>> https://docs.djangoproject.com/en/dev/topics/serialization/ the part
>>>> which
>>>> says "Serialization formats->JSON" there is an example of how the data
>>>> would
>>>> be serialized.
>>>> The sample uses the symbol "double quotation".
>>>>
>>>> On my machine I have django 1.6.1:
>>>>
>>>> C:\Documents and Settings\Igor.FORDANWORK>python
>>>> Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit
>>>> (Intel)]
>>>> on win32
>>>> Type "help", "copyright", "credits" or "license" for more information.
>>>> >>> import django
>>>> >>> django.get_version()
>>>> '1.6.1'
>>>> >>>
>>>>
>>>> In my views.py I'm using following code:
>>>>
>>>> usb_list = serializers.serialize("json", USB.objects.all())
>>>> return render_to_response('html/index.html', {"usb_data": usb_list} )
>>>>
>>>> where USB is the data model class.
>>>> This class overrides a __unicode__() function to produce a good output
>>>> on
>>>> the console.
>>>>
>>>> Now when I go to the page to see it in the browser I see the data as a
>>>> JSON but the data is surrounded with a text "".
>>>>
>>>> So in the docs I see something like this: "abc", while my application
>>>> will show: abc
>>>>
>>>> In the index.html I have this code:
>>>>
>>>> 
>>>> 
>>>> 
>>>> Test
>>>> {% load staticfiles %}
>>>> 
>>>> var data = "{{usb_data}}";
>>>> # some more JavaScript code
>>>> 
>>>> 
>>>> 
>>>>
>>>> Is this a recent change? Am I doing something wrong?
>>>> 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/783144af-8478-408a-bdd5-0b7b5a5a1161%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...@google

Re: JSON serialization

2014-01-18 Thread Igor Korot
Hi, guys,

On Sat, Jan 18, 2014 at 12:02 AM, Babatunde Akinyanmi
<tundeba...@gmail.com> wrote:
>
> On 18 Jan 2014 08:32, "Mario Gudelj" <mario.gud...@gmail.com> wrote:
>>
>> In your template try {{usb_data|safe}}
>
> ...because django escapes everything in the template by default except
> you ask not to. One of the methods of doing so if by using the `safe` filter
> like Mario suggested.
> You can read the documentation on how to escape or unescape stuff in your
> template.

Thank you, guys. It works.
Now I need to figure out why I still don't see my data in the jQWidget
control (jqxGrid)...

Anybody familiar with this library?

Thank you.
>
>>
>> On 18/01/2014 4:53 pm, "Igor Korot" <ikoro...@gmail.com> wrote:
>>>
>>> Hi, ALL,
>>> I'd like someone to help me understand this situation.
>>> Looking at the page:
>>> https://docs.djangoproject.com/en/dev/topics/serialization/ the part which
>>> says "Serialization formats->JSON" there is an example of how the data would
>>> be serialized.
>>> The sample uses the symbol "double quotation".
>>>
>>> On my machine I have django 1.6.1:
>>>
>>> C:\Documents and Settings\Igor.FORDANWORK>python
>>> Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)]
>>> on win32
>>> Type "help", "copyright", "credits" or "license" for more information.
>>> >>> import django
>>> >>> django.get_version()
>>> '1.6.1'
>>> >>>
>>>
>>> In my views.py I'm using following code:
>>>
>>> usb_list = serializers.serialize("json", USB.objects.all())
>>> return render_to_response('html/index.html', {"usb_data": usb_list} )
>>>
>>> where USB is the data model class.
>>> This class overrides a __unicode__() function to produce a good output on
>>> the console.
>>>
>>> Now when I go to the page to see it in the browser I see the data as a
>>> JSON but the data is surrounded with a text "".
>>>
>>> So in the docs I see something like this: "abc", while my application
>>> will show: abc
>>>
>>> In the index.html I have this code:
>>>
>>> 
>>> 
>>> 
>>> Test
>>> {% load staticfiles %}
>>> 
>>> var data = "{{usb_data}}";
>>> # some more JavaScript code
>>> 
>>> 
>>> 
>>>
>>> Is this a recent change? Am I doing something wrong?
>>> 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/783144af-8478-408a-bdd5-0b7b5a5a1161%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/CAHqTbj%3DO5ysO7cmVXFg8p-aTMbHNZ5gHA4iZ8JaVzNthVjsDkQ%40mail.gmail.com.
>>
>> For more options, visit https://groups.google.com/groups/opt_out.
>
> --
> You received this message because you are subscribed to a topic in the
> Google Groups "Django users" group.
> To unsubscribe from this topic, visit
> https://groups.google.com/d/topic/django-users/uoeNHy50ozI/unsubscribe.
> To unsubscribe from this group and all its topics, 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/CA%2BWjgXPc0BVPpkkjOij%2BG6otewyksH7Ur7ju%3DH%3DL7%2B8HX8ZVyw%40mail.gmail.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/CA%2BFnnTyzs3h%3Dga%3DKvPArxx2-eiCVFECVPMjqc6uYnpmO%3D2SAcw%40mail.gmail.com.
For more options, visit https://groups.google.com/groups/opt_out.


JSON serialization

2014-01-17 Thread Igor Korot
Hi, ALL,
I'd like someone to help me understand this situation.
Looking at the page: 
https://docs.djangoproject.com/en/dev/topics/serialization/ the part which 
says "Serialization formats->JSON" there is an example of how the data 
would be serialized.
The sample uses the symbol "double quotation".
 
On my machine I have django 1.6.1:
 
C:\Documents and Settings\Igor.FORDANWORK>python
Python 2.7.5 (default, May 15 2013, 22:43:36) [MSC v.1500 32 bit (Intel)] 
on win32
Type "help", "copyright", "credits" or "license" for more information. 
>>> import django
>>> django.get_version()
'1.6.1'
>>>
 
In my views.py I'm using following code:
 
usb_list = serializers.serialize("json", USB.objects.all())
return render_to_response('html/index.html', {"usb_data": usb_list} )
 
where USB is the data model class.
This class overrides a __unicode__() function to produce a good output on 
the console.
 
Now when I go to the page to see it in the browser I see the data as a JSON 
but the data is surrounded with a text "".
 
So in the docs I see something like this: "abc", while my application will 
show: abc
 
In the index.html I have this code:
 



Test
{% load staticfiles %}

var data = "{{usb_data}}";
# some more JavaScript code



 
Is this a recent change? Am I doing something wrong?
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/783144af-8478-408a-bdd5-0b7b5a5a1161%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Server return error 304

2014-01-16 Thread Igor Korot
Hi, ALL,
I'm getting an error 304 trying to locate the JavaScript files on my
dev machine.

Here's what I did.
I created a project and then created an application according to the tutorial.
Looking at https://docs.djangoproject.com/en/1.5/howto/static-files/ I
made sure that "STATIC" environment variable is defined.

Here is my structure:

artefacts (project)
|
|> (settings.py, urls.py, wsgi.py)
|
displayusbdata (application)
|
|---> (admin.py, models.py, tests.py, views.py)
|
|--> static
|
|> jqwidgets-ver3.1.0 (JavaScript files)
|
templates
|
|> html
   |
   |---> index.html

Now, the page (index.html) loads fine. When I go to "View->Source" (I
use IE here) I can see the code of the page.
Here is this code:

[code]



Test
{% load staticfiles %}













var data = "{{usb_data}}";
$(document).ready(function(){
var source =
{
localdata: data,
datatype: "json",
datafields:
[
{ name: '"device_name"', type: 'string' },
{ name: '"vid_pid"', type: 'date' },
{ name: '"install"', type: 'date' },
{ name: '"disk_device"', type: 'date' },
{ name: '"volume_device"', type: 'date' },
{ name: '"usb_type"', type: 'string' },
{ name: '"vid"', type: 'string' },
{ name: '"pid"', type: 'string' },
{ name: '"hub"', type: 'number' }
],
id: '"pk"',
root: '"fields"'
};
var dataAdapter = new $.jqx.dataAdapter(source)
//initialize jqxGrid
$("#grid").jqxGrid(
{
source: dataAdapter,
showstatusbar: true,
editable: false,
columns:
[
{ text: 'Device Name', columntype: 'textbox',
datafield: '"device_name"', width: 100 },
{ text: 'VID/PID', columntype: 'textbox', datafield:
'"vid_pid"', width: 50 },
{ text: 'Install', columntype: 'textbox', datafield:
'"install"', width: 50 },
{ text: 'Disk Device', columntype: 'textbox',
datafield: '"disk_device"', width: 50 },
{ text: 'Volume Device', columntype: 'textbox',
datafield: '"volume_device"', width: 50 },
{ text: 'Type', columntype: 'textbox', datafield:
'"usb_type"', width: 100 },
{ text: 'VID', columntype: 'textbox', datafield:
'"vid"', width: 100 },
{ text: 'PID', columntype: 'textbox', datafield:
'"pid"', width: 100 },
{ text: 'Hub', datafield: '"hub"',
cellsalign: 'right', cellsformat: 'n2' }
]
});
});








[/code]
However, on the terminal of my developmental server I see following:

[16/Jan/2014 01:26:05] "GET /usb/ HTTP/1.1" 200 223915
[16/Jan/2014 01:26:05] "GET
/static/jqwidgets-ver3.1.0/jqwidgets/styles/jqx.base.css HTTP/1.1" 304
0
[16/Jan/2014 01:26:05] "GET
/static/jqwidgets-ver3.1.0/jqwidgets/jqxcore.js HTTP/1.1" 304 0
[16/Jan/2014 01:26:05] "GET /static/jquery-1.10.2.js HTTP/1.1" 304 0
[16/Jan/2014 01:26:05] "GET
/static/jqwidgets-ver3.1.0/jqwidgets/jqxdata.js HTTP/1.1" 304 0
[16/Jan/2014 01:26:05] "GET
/static/jqwidgets-ver3.1.0/jqwidgets/jqxgrid.js HTTP/1.1" 304 0
[16/Jan/2014 01:26:05] "GET
/static/jqwidgets-ver3.1.0/jqwidgets/jqxgrid.sort.js HTTP/1.1" 304 0
[16/Jan/2014 01:26:05] "GET
/static/jqwidgets-ver3.1.0/jqwidgets/jqxscrollbar.js HTTP/1.1" 304 0
[16/Jan/2014 01:26:05] "GET
/static/jqwidgets-ver3.1.0/jqwidgets/jqxgrid.filter.js HTTP/1.1" 304 0
[16/Jan/2014 01:26:05] "GET
/static/jqwidgets-ver3.1.0/jqwidgets/jqxgrid.selection.js HTTP/1.1"
304 0
[16/Jan/2014 01:26:05] "GET
/static/jqwidgets-ver3.1.0/jqwidgets/jqxgrid.pager.js HTTP/1.1" 304 0
[16/Jan/2014 01:26:05] "GET
/static/jqwidgets-ver3.1.0/jqwidgets/jqxgrid.grouping.js HTTP/1.1" 304
0
[16/Jan/2014 01:26:05] "GET
/static/jqwidgets-ver3.1.0/jqwidgets/jqxgrid.aggregates.js HTTP/1.1"
304 0

Which means that the server returns the 304 error on my jQWidgets files.

What am I missing? Where should I put my jQWidgets files in order to
get 200 and see the page?

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 

Re: Anybody familiar with JavaScript: Page is empty

2014-01-10 Thread Igor Korot
Hi,

On Fri, Jan 10, 2014 at 1:34 AM, trojactory <aru...@gmail.com> wrote:
> Hi Igor,
>
> You can solve this in three ways:
>
> 1. Return a JSON object from Django as a string using dumps: This will keep
> your HTML file unchanged. The JSON file might not be exactly in the form you
> want. But if you know javascript then you can format it correctly into your
> table.

I'm thinking of using JSON.
However, for some reason when I initially tried it it errored out.
Will try it again and report.

>
> 2. Use Django templates: You don't seem to use AJAX so why take the trouble
> of using Javascript to built the table? Let Django templates create it for
> you! (Search for the  example here
> http://www.djangobook.com/en/2.0/chapter04.html )

Well, does Django have a template for doing sorting and grouping of
the table of data on the fly?
>From what I see the jqxGrid does have it.
Besides this more like a proof of concept, so I'd really like this to work.

>
> 3. Try the django-jqgrid app (https://github.com/gerry/django-jqgrid). I
> haven't used it but looks like a working solution.
>
> I would recommend the second option.

Thank you.

>
> Regards,
> Arun
>
>
> On Friday, January 10, 2014 2:30:20 PM UTC+5:30, Igor Korot wrote:
>>
>> Hi, ALL,
>> I have a little problem.
>> I'm trying to connect the Django based application with jQuery/jQWidgets
>> (specifically jqxGrid).
>>
>> Here's what I've done:
>>
>> This is my views.py file:
>>
>> [code]
>> def displayusbtable(request):
>> usb_list = USB.objects.all()
>> return render_to_response('html/index.html', {"usb_data": usb_list} )
>> [/code]
>>
>> This is my html/index.html file:
>>
>> [code]
>> 
>> 
>> 
>> Test
>> {% load staticfiles %}
>> 
>> > %}">
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> var data = "{{usb_data}}";
>> $(document).ready(function(){
>> var source =
>> {
>> localdata: data,
>> datatype: "array",
>> datafields:
>> [
>> { name: 'device_name', type: 'string' },
>> { name: 'vid_pid', type: 'string' },
>> { name: 'install', type: 'string' },
>> { name: 'disk_device', type: 'string' },
>> { name: 'volume_device', type: 'string' },
>> { name: 'usb_type', type: 'string' },
>> { name: 'vid', type: 'string' },
>> { name: 'pid', type: 'string' },
>> { name: 'hub', type: 'number' }
>> ]
>> };
>> var dataAdapter = new $.jqx.dataAdapter(source)
>> //initialize jqxGrid
>> $("#grid").jqxGrid(
>> {
>> source: dataAdapter,
>> showstatusbar: true,
>> editable: false,
>> columns:
>> [
>> { text: 'Device Name', columntype: 'textbox', datafield:
>> 'device_name', width: 100 },
>> { text: 'VID/PID', columntype: 'textbox', datafield:
>> 'vid_pid', width: 50 },
>> { text: 'Install', columntype: 'textbox', datafield:
>> 'install', width: 50 },
>> { text: 'Disk Device', columntype: 'textbox', datafield:
>> 'disk_device', width: 50 },
>> { text: 'Volume Device', columntype: 'textbox', datafield:
>> 'volume_device', width: 50 },
>> { text: 'Type', columntype: 'textbox', datafield:
>> 'usb_type', width: 100 },
>> { text: 'VID', columntype: 'textbox', datafield: 'vid',
>> width: 100 },
>> { text: 'PID', columntype: 'textbox', datafield: 'pid',
>> width: 100 },
>> { text: 'Hub', datafield: 'hub', cellsalign: 'right',
>> cellsformat: 'n2' }
>> ]
>> caption: "Test"
>> });
>> });
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> [/code]
>>
>> Everything looks good, except that the page comes up blank.
>> Looking at the "View/Source" I see this:
>>
>> [code]
>> 
>> 
>> 
>> Test
>>
>> > href="/static/jqwidgets-ver3.1.0/jqwidgets/styles/jqx.base.css"
>> type="text/css" />
>> 
>> > src="/static/jqwidgets-ver3.1.0/jqwidgets/jqxcore.js">
>> &g

Re: Anybody familiar with JavaScript: Page is empty

2014-01-10 Thread Igor Korot
Hi, Mario,

On Fri, Jan 10, 2014 at 1:25 AM, Mario Gudelj <mario.gud...@gmail.com> wrote:
> It's hard to tell what the issue is from what you've posted, Igor. Have you
> looked at Chrome inspector to see if there are any js errors in it? Or have
> you tried inspecting the page to see if it's not some weird css issue? Try
> placing usb_data into html outside of js or console.log data var to see
> what's sent back by django.

I don't have a Chrome here. Just an old IE8 + WinXP. ;-)
Looking at the Dev Console I don't see any errors.

The Django is actually sending the proper data to the page itself.

Any other suggestions?

Thank you.

>
> On 10/01/2014 8:00 pm, "Igor Korot" <ikoro...@gmail.com> wrote:
>>
>> Hi, ALL,
>> I have a little problem.
>> I'm trying to connect the Django based application with jQuery/jQWidgets
>> (specifically jqxGrid).
>>
>> Here's what I've done:
>>
>> This is my views.py file:
>>
>> [code]
>> def displayusbtable(request):
>> usb_list = USB.objects.all()
>> return render_to_response('html/index.html', {"usb_data": usb_list} )
>> [/code]
>>
>> This is my html/index.html file:
>>
>> [code]
>> 
>> 
>> 
>> Test
>> {% load staticfiles %}
>> 
>> > %}">
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> var data = "{{usb_data}}";
>> $(document).ready(function(){
>> var source =
>> {
>> localdata: data,
>> datatype: "array",
>> datafields:
>> [
>> { name: 'device_name', type: 'string' },
>> { name: 'vid_pid', type: 'string' },
>> { name: 'install', type: 'string' },
>> { name: 'disk_device', type: 'string' },
>> { name: 'volume_device', type: 'string' },
>> { name: 'usb_type', type: 'string' },
>> { name: 'vid', type: 'string' },
>> { name: 'pid', type: 'string' },
>> { name: 'hub', type: 'number' }
>> ]
>> };
>> var dataAdapter = new $.jqx.dataAdapter(source)
>> //initialize jqxGrid
>> $("#grid").jqxGrid(
>> {
>> source: dataAdapter,
>> showstatusbar: true,
>> editable: false,
>> columns:
>> [
>> { text: 'Device Name', columntype: 'textbox', datafield:
>> 'device_name', width: 100 },
>> { text: 'VID/PID', columntype: 'textbox', datafield:
>> 'vid_pid', width: 50 },
>> { text: 'Install', columntype: 'textbox', datafield:
>> 'install', width: 50 },
>> { text: 'Disk Device', columntype: 'textbox', datafield:
>> 'disk_device', width: 50 },
>> { text: 'Volume Device', columntype: 'textbox', datafield:
>> 'volume_device', width: 50 },
>> { text: 'Type', columntype: 'textbox', datafield:
>> 'usb_type', width: 100 },
>> { text: 'VID', columntype: 'textbox', datafield: 'vid',
>> width: 100 },
>> { text: 'PID', columntype: 'textbox', datafield: 'pid',
>> width: 100 },
>> { text: 'Hub', datafield: 'hub', cellsalign: 'right',
>> cellsformat: 'n2' }
>> ]
>> caption: "Test"
>> });
>> });
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> [/code]
>>
>> Everything looks good, except that the page comes up blank.
>> Looking at the "View/Source" I see this:
>>
>> [code]
>> 
>> 
>> 
>> Test
>>
>> > href="/static/jqwidgets-ver3.1.0/jqwidgets/styles/jqx.base.css"
>> type="text/css" />
>> 
>> > src="/static/jqwidgets-ver3.1.0/jqwidgets/jqxcore.js">
>> > src="/static/jqwidgets-ver3.1.0/jqwidgets/jqxdata.js">
>> > src="/static/jqwidgets-ver3.1.0/jqwidgets/jqxscrollbar.js">
>> > src="/static/jqwidgets-ver3.1.0/jqwidgets/jqxgrid.js">
>> > src="/static/jqwidgets-ver3.1.0/jqwidgets/jqxgrid.sort.js">
>> > src="/static/jqwidgets-ver3.1.0/jqwidgets/jqxgrid.filter.js">
>> > src="/static/jqwidgets-ver3.1.0/jqwidgets/jqxgrid.aggregates.js">
>> > src="/static/jqwid

Anybody familiar with JavaScript: Page is empty

2014-01-10 Thread Igor Korot
Hi, ALL,
I have a little problem.
I'm trying to connect the Django based application with jQuery/jQWidgets 
(specifically jqxGrid).
 
Here's what I've done:
 
This is my views.py file:
 
[code]
def displayusbtable(request):
usb_list = USB.objects.all()
return render_to_response('html/index.html', {"usb_data": usb_list} )
[/code]
 
This is my html/index.html file:
 
[code]



Test
{% load staticfiles %}













var data = "{{usb_data}}";
$(document).ready(function(){
var source =
{
localdata: data,
datatype: "array",
datafields:
[
{ name: 'device_name', type: 'string' },
{ name: 'vid_pid', type: 'string' },
{ name: 'install', type: 'string' },
{ name: 'disk_device', type: 'string' },
{ name: 'volume_device', type: 'string' },
{ name: 'usb_type', type: 'string' },
{ name: 'vid', type: 'string' },
{ name: 'pid', type: 'string' },
{ name: 'hub', type: 'number' }
]
};
var dataAdapter = new $.jqx.dataAdapter(source)
//initialize jqxGrid
$("#grid").jqxGrid(
{
source: dataAdapter,
showstatusbar: true,
editable: false,
columns:
[
{ text: 'Device Name', columntype: 'textbox', datafield: 
'device_name', width: 100 },
{ text: 'VID/PID', columntype: 'textbox', datafield: 
'vid_pid', width: 50 },
{ text: 'Install', columntype: 'textbox', datafield: 
'install', width: 50 },
{ text: 'Disk Device', columntype: 'textbox', datafield: 
'disk_device', width: 50 },
{ text: 'Volume Device', columntype: 'textbox', datafield: 
'volume_device', width: 50 },
{ text: 'Type', columntype: 'textbox', datafield: 
'usb_type', width: 100 },
{ text: 'VID', columntype: 'textbox', datafield: 'vid', 
width: 100 },
{ text: 'PID', columntype: 'textbox', datafield: 'pid', 
width: 100 },
{ text: 'Hub', datafield: 'hub', cellsalign: 'right', 
cellsformat: 'n2' }
]
caption: "Test"
});
});








[/code]
 
Everything looks good, except that the page comes up blank.
Looking at the "View/Source" I see this:
 
[code]



Test
 












 
var data = "[<USB: pk: 1, device_name: wd ses_device, vid_pid: None, 
install: None, disk_device: None, volume_device: None, USB_type: other, 
PID: #0748, Vendor: wd, Product: ses_device, Revision: #1019>, <USB: 
pk: 2, device_name: wd ses_device, vid_pid: None, install: None, 
disk_device: None, volume_device: None, USB_type: other, PID: #0748, 
Vendor: wd, Product: ses_device, Revision: #1019>, <...(remaining 
elements truncated)...']";
$(document).ready(function(){
var source =
{
localdata: data,
datatype: "array",
datafields:
[
{ name: 'device_name', type: 'string' },
{ name: 'vid_pid', type: 'string' },
{ name: 'install', type: 'string' },
{ name: 'disk_device', type: 'string' },
{ name: 'volume_device', type: 'string' },
{ name: 'usb_type', type: 'string' },
{ name: 'vid', type: 'string' },
{ name: 'pid', type: 'string' },
{ name: 'hub', type: 'number' }
]
};
var dataAdapter = new $.jqx.dataAdapter(source)
//initialize jqxGrid
$("#grid").jqxGrid(
{
source: dataAdapter,
showstatusbar: true,
editable: false,
columns:
[
{ text: 'Device Name', columntype: 'textbox', datafield: 
'device_name', width: 100 },
{ text: 'VID/PID', columntype: 'textbox', datafield: 
'vid_pid', width: 50 },
{ text: 'Install', columntype: 'textbox', datafield: 
'install', width: 50 },
{ text: 'Disk Device', columntype: 'textbox', datafield: 
'disk_device', width: 50 },
{ text: 'Volume Device', columntype: 'textbox', datafield: 
'volume_device', width: 50 },
{ text: 'Type', columntype: 'textbox', datafield: 
'usb_type', width: 100 },
{ text: 'VID', columntype: 'textbox', datafield: 'vid', 
width: 100 },
{ text: 'PID', columntype: 'textbox', datafield: 'pid', 
width: 100 },
{ text: 'Hub', datafield: 'hub', cellsalign: 'right', 
cellsformat: 'n2' }
]
caption: "Test"
});
});








[/code]
What I think I am missing is a mapping between the Python/Django dictionary 
and the JavaScript/jqxGrid control.
 
Can someone please take a look?
 
Thank you.
 

-- 
You received this message because you 

Re: Question about the __unicode__()

2014-01-08 Thread Igor Korot
Tundebabzy,
I understand that.
But at the same time it should make some sense, otherwise what is the point 
of having this label (__unicode__() function), right?

Thank you.


On Wednesday, January 8, 2014 3:03:58 PM UTC-8, Igor Korot wrote:
>
> Hi, ALL,
> In the tutorial it is said that I need to create __unicode__() function to 
> properly display the results of my model.
> Unfortunately the tutorial is using only one text field and everywhere I 
> looked people are using something related, i.e. first_name+last_name and so 
> they can create a tuple.
>
> What if my strings are not related to each other at all?
> For example I might have:
>
> from django.db import models
>
> class Stuff(models.Model):
>  Manufacturer = models.CharField(max_length=100)
>  Serial_number = models.CharField(max_length=20)
>
> manufacturer and serial_number are not related and I don't want them to be 
> displayed as one field in the output.
> So what the __unicode__() function will look like in this case?
>
> 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/db824af5-ca40-4f04-b4c8-dd753f2a7b88%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Question about the __unicode__()

2014-01-08 Thread Igor Korot
Hi, Avraham,
So, lets say I write something like this:

[code]
def __unicode__(self):
 return (%s %s) manufacturer, serial_number
[/code]

and in tutorial part 1 I will go to the section "Play with API" I will 
still see 2 different fields when I issue: "Stuff.objects.all()"?

Because as far as I understand those 2 fields will be displayed as one.

Thank you.


On Wednesday, January 8, 2014 3:03:58 PM UTC-8, Igor Korot wrote:
>
> Hi, ALL,
> In the tutorial it is said that I need to create __unicode__() function to 
> properly display the results of my model.
> Unfortunately the tutorial is using only one text field and everywhere I 
> looked people are using something related, i.e. first_name+last_name and so 
> they can create a tuple.
>
> What if my strings are not related to each other at all?
> For example I might have:
>
> from django.db import models
>
> class Stuff(models.Model):
>  Manufacturer = models.CharField(max_length=100)
>  Serial_number = models.CharField(max_length=20)
>
> manufacturer and serial_number are not related and I don't want them to be 
> displayed as one field in the output.
> So what the __unicode__() function will look like in this case?
>
> 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/9f1ac883-a573-4f02-b9ef-c6f6e57c6453%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Re: Question about the __unicode__()

2014-01-08 Thread Igor Korot
Hi, Avraham,
Well, I'm looking for a way to "properly" override this function.
The problem is that I have a lot more text fields in a table/model than 
just 2, but they are not related as in my example first and last name.

So what would be the proper implementation?

Because right now following tutorial, I don't see a database text when 
displaying the records.

Thank you.


On Wednesday, January 8, 2014 3:03:58 PM UTC-8, Igor Korot wrote:
>
> Hi, ALL,
> In the tutorial it is said that I need to create __unicode__() function to 
> properly display the results of my model.
> Unfortunately the tutorial is using only one text field and everywhere I 
> looked people are using something related, i.e. first_name+last_name and so 
> they can create a tuple.
>
> What if my strings are not related to each other at all?
> For example I might have:
>
> from django.db import models
>
> class Stuff(models.Model):
>  Manufacturer = models.CharField(max_length=100)
>  Serial_number = models.CharField(max_length=20)
>
> manufacturer and serial_number are not related and I don't want them to be 
> displayed as one field in the output.
> So what the __unicode__() function will look like in this case?
>
> 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/fd76cc47-1560-4be1-a040-af0af17b60d1%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


Question about the __unicode__()

2014-01-08 Thread Igor Korot
Hi, ALL,
In the tutorial it is said that I need to create __unicode__() function to 
properly display the results of my model.
Unfortunately the tutorial is using only one text field and everywhere I 
looked people are using something related, i.e. first_name+last_name and so 
they can create a tuple.

What if my strings are not related to each other at all?
For example I might have:

from django.db import models

class Stuff(models.Model):
 Manufacturer = models.CharField(max_length=100)
 Serial_number = models.CharField(max_length=20)

manufacturer and serial_number are not related and I don't want them to be 
displayed as one field in the output.
So what the __unicode__() function will look like in this case?

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/3cb9594d-718f-424c-9d36-25bce866bf2b%40googlegroups.com.
For more options, visit https://groups.google.com/groups/opt_out.


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.