Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

removes dojango dependency. #3

Merged
merged 1 commit into from

2 participants

@jaanauati

Removes dojango dependency.
Adds support for "lazy reversed" urls (see README file).

Jonatan Alexis Anauati Removes dojango dependency.
Adds support for "lazy reversed" urls (see README file).
2b2bea1
@gerry gerry merged commit 21aa024 into gerry:master
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Commits on May 29, 2012
  1. Removes dojango dependency.

    Jonatan Alexis Anauati authored
    Adds support for "lazy reversed" urls (see README file).
This page is out of date. Refresh to see the latest.
Showing with 14 additions and 10 deletions.
  1. +1 −2  README
  2. +13 −8 jqgrid.py
View
3  README
@@ -10,7 +10,6 @@ handler), and adding documentation/examples soon. Until then, you have been
warned!
== Prerequisites ==
- * [http://code.google.com/p/dojango/source/browse/trunk/dojango/util/__init__.py#97 json_encode]
* [http://www.jquery.com jQuery 1.3+]
* [http://www.trirand.com/blog/?page_id=6 jqGrid 3.5+]
@@ -22,7 +21,7 @@ warned!
class ExampleGrid(JqGrid):
model = SomeFancyModel # could also be a queryset
fields = ['id', 'name', 'desc'] # optional
- url = reverse('grid_handler')
+ url = reverse_lazy('grid_handler')
caption = 'My First Grid' # optional
colmodel_overrides = {
'id': { 'editable': False, 'width':10 },
View
21 jqgrid.py
@@ -34,8 +34,12 @@
from django.utils import simplejson as json
from django.utils.encoding import smart_str
from django.http import Http404
-from util.json import json_encode
+from dojango.util import json
+from django.core.serializers.json import DjangoJSONEncoder
+def json_encode(data):
+ encoder = DjangoJSONEncoder()
+ return encoder.encode(data)
class JqGrid(object):
queryset = None
@@ -187,12 +191,13 @@ def paginate_items(self, request, items):
def get_json(self, request):
paginator, page, items = self.get_items(request)
- return json_encode({
- 'page': page.number,
- 'total': paginator.num_pages,
- 'rows': items,
- 'records': paginator.count
- })
+ data={
+ 'page': int(page.number),
+ 'total': int(paginator.num_pages),
+ 'rows': [obj for obj in items],
+ 'records': int(paginator.count),
+ }
+ return json_encode(data)
def get_default_config(self):
config = {
@@ -220,7 +225,7 @@ def get_default_config(self):
return config
def get_url(self):
- return self.url
+ return str(self.url)
def get_caption(self):
if self.caption is None:
Something went wrong with that request. Please try again.