From 7e20386682c0e0c3a7a82923193c314b76588768 Mon Sep 17 00:00:00 2001 From: Ankush Chadda Date: Sat, 10 Sep 2016 16:11:36 +0530 Subject: [PATCH 1/3] ordering contance fields using OrderedDict --- constance/admin.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/constance/admin.py b/constance/admin.py index a365509..5535e8f 100644 --- a/constance/admin.py +++ b/constance/admin.py @@ -2,6 +2,7 @@ from datetime import datetime, date, time from decimal import Decimal import hashlib from operator import itemgetter +from collections import OrderedDict from django import forms, VERSION from django.conf.urls import url @@ -202,7 +203,8 @@ class ConstanceAdmin(admin.ModelAdmin): 'config_values': config_values }) - context['config_values'].sort(key=itemgetter('name')) + if not isinstance(settings.CONFIG_FIELDSETS, OrderedDict): + context['config_values'].sort(key=itemgetter('name')) request.current_app = self.admin_site.name # compatibility to be removed when 1.7 is deprecated extra = {'current_app': self.admin_site.name} if VERSION < (1, 8) else {} From b9eb800a916e911094021fa4efb06deedc8ebf15 Mon Sep 17 00:00:00 2001 From: Ankush Chadda Date: Sat, 10 Sep 2016 16:18:52 +0530 Subject: [PATCH 2/3] Documentation changes for Ordered fields in admin --- docs/index.rst | 18 +++++++++++++++++- 1 file changed, 17 insertions(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 71fec82..39f8f30 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -118,8 +118,24 @@ Note: Use later evaluated strings instead of direct classes for the field and wi 'MY_SELECT_KEY': ('yes', 'select yes or no', 'yes_no_null_select'), } +Ordered Fields in admin +----------------------- + +In order to Order the fields , you can use OrderedDict collection. Here is an example: + +.. code-block:: python + + from collections import OrderedDict + + CONSTANCE_CONFIG = OrderedDict([ + ('SITE_NAME', ('My Title', 'Website title')), + ('SITE_DESCRIPTION', ('', 'Website description')), + ('THEME', ('light-blue', 'Website theme')), + ] + + Fieldsets -------------- +--------- To group settings together you can define fieldsets. Here's an example: From bee1a68c51f150ef3659d4e0768292f2e1324ce9 Mon Sep 17 00:00:00 2001 From: Ankush Chadda Date: Sat, 10 Sep 2016 16:53:52 +0530 Subject: [PATCH 3/3] Change to test travis build --- docs/index.rst | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/index.rst b/docs/index.rst index 39f8f30..9ded059 100644 --- a/docs/index.rst +++ b/docs/index.rst @@ -118,7 +118,7 @@ Note: Use later evaluated strings instead of direct classes for the field and wi 'MY_SELECT_KEY': ('yes', 'select yes or no', 'yes_no_null_select'), } -Ordered Fields in admin +Ordered Fields in Django Admin ----------------------- In order to Order the fields , you can use OrderedDict collection. Here is an example: