3

I'm pretty newbie to world of python, mongodb and django. (coming from java ee world)

I have task to represent some collection from mongodb as html table in django. Table should is editable, so rows, columns and fields can be edited, added, removed. Also some of it can be set: bold, italic etc.

So, editing of data in that table should not have effect on data in collection in mongodb, it is ment to be saved once user is satisfied with it.

I've setup django and mongodb, with pymongo module. Also spotted this project: http://www.datatables.net/development/server-side/django

Can somebody advise me how to pull this off (wich modules/software can be leveraged to speed this up)?

Sole
  • 61
  • 2
  • 6

2 Answers2

1

The jquery dataTables plugin is easy to use and it helps with sorting, paging and filtering your data. Unless you have a lot of data rows you might not need to use serverside implementations for dataTables. You can simply build the table somehow in you django view and then use dataTables like so:

$('#table-id').dataTable();

Sorting etc will work. The serverside implementation is only really necessary if you have to many data rows to be handled by the browser efficiently (1000+) or if traffic limitations are more important than rendering speed (server side implementations need to wait for an ajax request each time filtering, sorting or paging is used).

DataTables dont, however, offer functionality to edit Data. You should consider using jeditable or similar plugins if you dont want to write your own code for that. In order to save changes you will have to create a handler in django (I think view is how they call it)

joidegn
  • 1,078
  • 9
  • 19
  • Thanks for this clarification Joi, I've already started to experiment with datatables.net, but their example app with django integration won't work with django 2.7 – Sole Feb 19 '12 at 19:12
  • datatables really only needs django to return data in a certain style (i.e. see http://datatables.net/usage/server-side). So if you manage to make django 2.7 return the data in that style which should be doable datatables will work – joidegn Feb 21 '12 at 15:38
1

You may consider dojango-datatable, a project which integrates the Dojo toolkit with Django.

For what you are looking for, I imagine you may still need to write some custom code. But it should get you started in the right direction.

http://code.google.com/p/dojango-datable/

Dojango Data Tables allows you to define table layout and column types in Python instead of JS or HTML. It also includes a few template tags to create HTML required for the dojo.DataGrid in a configurable manner.

If dojango-datatable is not flexible enough, you could try using django-piston to create a JSON rest service for Django and then use either Dojo or another front end UI with the rest service to accomplish what you need to.

For django-piston, check out this discussion: Django and Restful APIs

Community
  • 1
  • 1
Tom Gruner
  • 9,635
  • 1
  • 20
  • 26