Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Add the setting AJAX_PK_ATTR_NAME so you can specify what the Model's…

… pk will be named in the output.
  • Loading branch information...
commit 4d0b29c1083d8613e3f3103aa3522cba9bca32ac 1 parent 6985a23
@joestump authored
Showing with 6 additions and 1 deletion.
  1. +6 −1 ajax/encoders.py
View
7 ajax/encoders.py
@@ -2,12 +2,17 @@
from ajax.exceptions import AlreadyRegistered, NotRegistered
from django.db.models.fields import FieldDoesNotExist
from django.db import models
+from django.conf import settings
from django.utils.html import escape
from django.db.models.query import QuerySet
from django.utils.encoding import smart_str
import collections
+# Used to change the field name for the Model's pk.
+AJAX_PK_ATTR_NAME = getattr(settings, 'AJAX_PK_ATTR_NAME', 'pk')
+
+
class DefaultEncoder(object):
_mapping = {
'IntegerField': int,
@@ -25,7 +30,7 @@ def to_dict(self, record, expand=False, html_escape=False):
ret = {}
ret.update(data['fields'])
- ret['pk'] = data['pk']
+ ret[AJAX_PK_ATTR_NAME] = data['pk']
for field, val in ret.iteritems():
try:
Please sign in to comment.
Something went wrong with that request. Please try again.