1. Curtis Maloney
  2. gnocchi-faq

Commits

funkybob  committed 3b16e60 Draft

Add support for Grappelli

  • Participants
  • Parent commits 0276810
  • Branches default

Comments (0)

Files changed (1)

File gnocchi/faq/admin.py

View file
 from django.contrib import admin
 from gnocchi.faq import models
+from django import forms
+
+try:
+    import grappelli
+    HAVE_GRAPPELLI = True
+except ImportError:
+    HAVE_GRAPPELLI = False
 
 class QuestionInline(admin.StackedInline):
     model = models.Question
     prepopulated_fields = {
         'slug': ('question',)
     }
+    # enabling drag'n'drop reordering for Grappelli
+    if HAVE_GRAPPELLI:
+        sortable_field_name = 'order',
+        formfield_overrides = {
+            models.models.PositiveIntegerField: {
+                'widget': forms.HiddenInput
+            },
+        }
+
 
 class CategoryAdmin(admin.ModelAdmin):
     list_display = ('title', 'order',)